Export GC memory manager to C???
Vladimir Panteleev
vladimir at thecybershadow.net
Thu Jul 28 11:40:21 PDT 2011
On Thu, 28 Jul 2011 13:31:01 +0300, Robert Persson <r.k.persson at gmail.com>
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:vladimir at thecybershadow.net
More information about the Digitalmars-d
mailing list