unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Andrew Gaylard <ag@computer.org>
To: guile-user@gnu.org
Subject: Re: smob gc protection, and inheritance
Date: Thu, 05 Sep 2013 21:43:54 +0200	[thread overview]
Message-ID: <5228DEFA.4030700@computer.org> (raw)
In-Reply-To: <87y57c70js.fsf@gnu.org>

On 09/04/13 23:13, Ludovic Courtès wrote:
> Hi Doug,
>
> Doug Evans <dje@sebabeach.org> 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
(http://lists.gnu.org/archive/html/guile-user/2013-08/msg00133.html).

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,

-- 
Andrew




  reply	other threads:[~2013-09-05 19:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-03 19:27 smob gc protection, and inheritance Doug Evans
2013-09-04 21:13 ` Ludovic Courtès
2013-09-05 19:43   ` Andrew Gaylard [this message]
2013-09-06 12:19     ` Ludovic Courtès
2013-09-07  8:22 ` Andy Wingo
2013-09-07 14:17   ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5228DEFA.4030700@computer.org \
    --to=ag@computer.org \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).