[Gc] Manually adding/removing threads
Hans.Boehm at hp.com
Sat Mar 4 19:06:38 PST 2006
In gc6.x this is more platform dependent than I would like. Things
are somewhat more rational in 7.0alpha, but I assume that's not
what you're using.
On Unix/Linux platforms, threads created with GC_pthread_create are
traced. Gc.h redefines pthread_create to GC_pthread_create. Thread
creation that bypasses this mechanism results in threads that are
unknown to the GC, and hence neither stopped nor traced. If you
allocate from the garbage collected heap, or manipulate pointers to
GC memory from such threads, the results will be very unpleasant.
However, you can use this mechanism to hide threads from the GC.
On Windows, things are a bit more complicated. The collector can do
something similar if it's in a static library. If it's in a dynamic
library, it generally tries to track down all threads in the process.
On Sat, 4 Mar 2006, Lothar Scholz wrote:
> i don't like the default way that the garbage collector tries to find
> and check every thread running in the process as i may have a few dozens
> python or pure C++ threads that do not use any of the GC memory.
> I already use GC_no_dls and GC_add_roots to prevent this for memory.
> Is there any way to do this for threads ?
> I tried to read the source code but it seems that over the years
> it became quite unreadable and will need a lot of time to study this.
> More then i can afford at the moment.
> Best regards,
> Lothar Scholz mailto:scholz at scriptolutions.com
> Gc mailing list
> Gc at linux.hpl.hp.com
More information about the Gc