[Gc] Re: Using the GC from a DLL

Hans Boehm Hans.Boehm at hp.com
Sun Jan 6 18:23:51 PST 2008

On Sun, 6 Jan 2008, Achilleas Margaritis wrote:

> Could you please confirm the following:
> 1) GC_malloc can be invoked before GC_INIT either from a DLL or from the
>  program.
This is platform specific.  On Linux, and I believe on Windows with Msft 
tools, this is correct.  It initializes the collector on demand.  On AIX 
and Cygwin it is not.  Hence it is not correct for portable code.
> 2) GC_INIT must be invoked from main() and not from the DLL.
That is platform specific in the same way.  The real problem is that there
are platforms on which initialization code must be invoked from the
main program before it is safe to run a GC, because the collector has no 
other ways to determine the bounds of statically allocated roots.  On 
those platforms (AIX and Cygwin) GC_INIT must be called from the main 
program before it is safe to run a collection.  (It may be OK to
perform a small number of allocations before GC_INIT on those platforms; 
I'm not sure, and haven't tried it.)


> Thanks.
> O/H Boehm, Hans ??????:
>> The CVS version forces initialization on a GC_malloc call.  Version 7.0 does not.  Even with the CVS version, some more esoteric calls might cause problems if they are made before initialization.
>> Hans
>>> -----Original Message-----
>>> From: gc-bounces-o/PNRNCSakrWxDs0y9d3MAC/G2K4zDHf at public.gmane.org
>>> [mailto:gc-bounces-o/PNRNCSakrWxDs0y9d3MAC/G2K4zDHf at public.gmane.org] On Behalf Of Achilleas
>>> Margaritis
>>> Sent: Monday, December 31, 2007 1:47 AM
>>> To: gc-o/PNRNCSakrWxDs0y9d3MAC/G2K4zDHf at public.gmane.org
>>> Subject: [Gc] Using the GC from a DLL
>>> How can I use the GC from inside a DLL?
>>> What if the DLL does allocations in its initialization code
>>> before I am given a chance to call GC_INIT?
>>> _______________________________________________
>>> Gc mailing list
>>> Gc-V9/bV5choksm30D7ZfaTJw at public.gmane.org
>>> https://www.hpl.hp.com/hosted/linux/mail-archives/gc/

More information about the Gc mailing list