[gclist] Boehm's GC: marking collectable mem as uncollectable?

Hans Boehm boehm@hoh.mti.sgi.com
Wed, 8 Apr 1998 09:44:47 -0700

On Apr 8,  5:24pm, Stephan Rudlof wrote:
> I prefer Solution 2: Collectable pointers as default and user *has* to
> call a function, which transforms them in uncollectable pointers, if he
> wants to store them in malloc'ed mem. Then I have some freedom dealing
> with setjump/longjump and one parameter less for ordinary calls.
Note that there are effectively two ways to make something uncollectable:

1) Allocate the object with GC_malloc_uncollectable, or
2) Store a pointer to it in some global data structure

Given the way the collector is implemented, you can't change the collectability
of an objects without copying in case (1).  (Actually you could for large
objects, but there's currently no interface to do so.)  The second alternative
does allow you to make an object uncollectable after the fact.  But it has some

- It takes more space for the global data structure.
- You need to call a custom deallocation function, which needs to find the
pointer in the global data structure.  This process is likely to be slower than
a call to either GC_free or the C library free operation.

You may still want to consider it here.

Hans-J. Boehm