On Thu, 28 Jul 2011 13:31:01 +0300, Robert Persson <[email protected]> wrote:

Would it be possible to export GC.malloc(...) as a C function in a DLL, to
use as a garbage collected memory allocator for C ? Or does the garbage
collector not scan outside the boundaries of the DLL?

/Robert Persson, Sweden

To use D's garbage collector in another environment, you'd need to do the following:

1) Use the GC for allocation, naturally
2) Specify the boundaries of the data segment, containing global and static variables
3) Inform the GC of all threads, so that it can scan their stacks
4) If any of your objects require finalization upon collection, you'd need to find a way to integrate that.

D's garbage collector is based on the Boehm GC, which was written for C/C++. You may want to use that instead.

http://www.hpl.hp.com/personal/Hans_Boehm/gc/

--
Best regards,
 Vladimir                            mailto:[email protected]

Reply via email to