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

Jeremy Fitzhardinge jeremy@zip.com.au
Thu, 09 Apr 1998 11:36:19 +1000


Stephan Rudlof wrote:
> 
> Is there any possibility to *later* mark collectable allocated memory as
> uncollectable?
> 
> Problem: I'm working at a library and want to use GC for it. But I don't
> want to force users of the library to work with GC. So I have to solve
> the problem returning pointers to users as uncollectable. If all
> functions in the library would return uncollectable pointers at default,
> it would be a problem to call functions of the library internally from
> other functions in it: Then I want to use GC!

When you allocate you could tack space for a couple of extra pointers
onto the allocation.  When you return it to user code, you use them to
put the object on a linked list of unfreeable things.  When you manually
free, you unlink it from the list and either let the GC have its evil
way with it, or use an explicit free.

	J