[Top][All Lists]

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

Re: Calling scheme from C: problem with GC.

From: Martin Grabmueller
Subject: Re: Calling scheme from C: problem with GC.
Date: Wed, 28 Nov 2001 16:37:51 +0100 (MET)

> From: Rob Browning <address@hidden>
> Date: Mon, 26 Nov 2001 15:23:31 -0600
> Chris Cramer <address@hidden> writes:
> > I think what you need is scm_gc_protect_object(). It takes one argument,
> > the object you want to protect from garbage collection. Unprotect it with
> > scm_gc_unprotect_object(). If you want to protect multiple objects, it
> > may be a better idea to place them in a vector or list and then protect
> > that (since protecting an object also protects everything it references).
> I've seen this suggested in a number of places, but what's the harm in
> just always using scm_protect/unprotect_object.  Is there some
> performance penalty or similar if you're using it for a large number
> of items?

IIRC, scm_protect/scm_unprotect put their argument into a hash table
and delete it from a hash table, so each time one of them is called, a
table search happens.  Putting references into a vector or list avoids
this.  Even better are the new mechanisms for registering GC roots,
though the new function names have slipped my mind...


reply via email to

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