guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Smobs & garbage collecting


From: Stephen Compall
Subject: Re: Smobs & garbage collecting
Date: Sun, 01 Jan 2006 14:16:56 -0600

On Fri, 2005-12-30 at 21:20 +0100, Christian Mauduit wrote:
> I found out that the problem disappeared when I decided to make my free
> callback (the one set up with scm_set_smob_free) return systematically a
> value of 0. I understand the return value of this function should
> reflect the amount of freed memory and be a hint for Guile to optimize
> memory management. Point is I do not use scm_must_malloc to allocate
> memory and Guile doesn't know when I allocate memory.
> 
> It's a design option of my program to have independent chunk of codes
> (libraries in fact) which are absolutely not aware that they are used in
> a Guile context, so allocating memory with scm_must_malloc does not
> really make sense for them. In fact it's not even acceptable, one could
> wish to use these objects without using Guile at all.

Maybe this suggestion is worthless, but: many independent libraries
carry global variables for exactly this reason, for the memory
allocation functions they use, so that library users can change how
memory is allocated, such as with the `dmalloc' functions.  As for the
differing signatures of scm_must_malloc and malloc, you could wash over
either with a utility function, or even use the WHAT argument to add
more details to your memory statistics [in debug mode only, of course!]
or just in-source documentation of your mallocations.

-- 
Stephen Compall
http://scompall.nocandysw.com/blog

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]