[Gc] boehm gc and libraries...

Boehm, Hans hans.boehm at hp.com
Fri Jan 13 15:16:23 PST 2006


Assuming those libraries continue to call the system malloc (i.e. you
haven't built the GC with malloc redirection or redefined malloc
yourself), you will need to continue to free objects where you otherwise
would.

You can use GC_register_finalizer to get the GC to automatically perform
the deallocation when garbage-collected objects become unreachable.  But
finalization is a tricky mechanism to use correctly, no matter which
library or language you are dealing with.  (I gave a talk on this in a
Java context at JavaOne last year.  Slides are at
http://www.hpl.hp.com/personal/Hans_Boehm/misc_slides/java_finalizers.pd
f .  Generally the same concerns apply here, though you want to use
somewhat different mechanisms.  If you're not using threads, things
change a little.)

Hans

> -----Original Message-----
> From: gc-bounces at napali.hpl.hp.com 
> [mailto:gc-bounces at napali.hpl.hp.com] On Behalf Of kevin lyda
> Sent: Friday, January 13, 2006 1:30 AM
> To: gc at napali.hpl.hp.com
> Subject: [Gc] boehm gc and libraries...
> 
> 
> In reading through the Boehm GC docs, I'm still not clear how 
> it deals with libraries that don't use the Boehm GC.  The 
> simple example would be libc's strdup.  But there are more 
> complex examples - a DB client library for MySQL, Postgres, 
> sqlite or libdbi; a GUI library like gtk, qt or libX11; etc.
> 
> Do I still need to free those pointers, or can I safely 
> depend on the gc to notice them?  Or is there a middle ground 
> where I can notify the GC that these addresses have been alloced?
> 
> Thanks,
> 
> Kevin
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com 
> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
> 



More information about the Gc mailing list