[Top][All Lists]

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

Re: smob gc protection, and inheritance

From: Andrew Gaylard
Subject: Re: smob gc protection, and inheritance
Date: Thu, 05 Sep 2013 21:43:54 +0200
User-agent: Mozilla/5.0 (X11; SunOS sun4u; rv:17.0) Gecko/20130802 Thunderbird/17.0.8

On 09/04/13 23:13, Ludovic Courtès wrote:
Hi Doug,

Doug Evans <address@hidden> skribis:
3) The docs aren't as clear as they could be on whether the "smob"
free function needs to scm_gc_free all results of calls to scm_gc_malloc
made when constructing the smob.  IIUC, this is not necessary.
The ‘scm_gc_free’ function doesn’t need to be called nowadays, because
the GC automatically frees ‘scm_gc_malloc’ regions when they are no
longer referenced.

So chances are you don’t even need a SMOB ‘free’ function.

However, why does the image example do this?
Indeed, the ‘mark’ and ‘free’ functions in that example could be removed
altogether, since the only resources associated with the SMOB is memory
returned by ‘scm_gc_malloc’.
Hi Ludo',

Thanks for this information -- it helps answer my guile-dbi question

You say "chances are" -- so when does one need a free() function?
I suspect that guile-dbi does require one, because it has to close
the DB handle; right?

Since the SMOB was allocated with scm_gc_malloc, and since the
things it mark()s are all SCM types, does it follow that it's safe not to
mark() it at all?

Where can I find more information about how guile and its GC work?
In particular, is there a FAQ guide to debugging GC problems?
I'm concerned about leaks, objects collected/freed too early, and
similar bugs.

BTW: all of this is in the context of guile-2.0.9.

Many thanks,


reply via email to

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