GC, Multithreading, Heap(s)

g012 crashman at free.fr
Wed Nov 5 14:42:07 PST 2008


Hello,

I'm not yet programming seriously in D, but I've been lurking on it since
quite some years now, and I have some questions about its current (or
future ?) features related to memory that need answers before the decisive
jump.

In the context of a multithreaded program, I'd like to know if it's
possible to do the following in D (if a feature is not currently supported,
can you indicate if it's planned for a future release):

 . replacing the default heap allocator with a multithread optimized one,
like nedmalloc. I saw I can overload new and delete in a class / struct,
but I'd like to do the overload on the generic new / delete. If it's not
possible, does the default allocator already support multithreaded heap
allocations without locking systematically ?

 . is the GC multithreaded, ie when it pauses all the threads to run, does
it run multithreaded itself, with one thread per hardware thread ?

 . if a thread has data to be collected that only itself is referencing,
will a dedicated GC thread run in parallel of the other threads (themselves
running as normal, unpaused, simultaneously to the thread-local GC) ? If
no, is there a way to declare that a variable will be referenced only in
the current thread, and to have a thread-specific collector that does not
imply to pause other threads to run ? The idea is to collect thread-local
variables by a thread-locale GC, and shared variables by the global GC. And
if it is possible, can we disable temporarily thread-local GC similarly to
the global GC ?

If anything that can optimize heap usage in threads better than the above
points is already implemented (or planned to) in D, please explain it to me
:)

Thanks a lot for your help.

Pascal



More information about the Digitalmars-d mailing list