A benchmark, mostly GC

Jakob Ovrum jakobovrum at gmail.com
Mon Dec 12 08:09:41 PST 2011


On Monday, 12 December 2011 at 16:00:04 UTC, Manu wrote:
> Totally off topic... I have a question.
>
> If I pass a pointer to a C library... how does the GC know when 
> it's safe
> to collect?

It doesn't, you should add it to the GC with GC.addRoot or 
GC.addRange unless you're absolutely sure the pointer is never 
taken off the stack (the call stack is shared between the C and D 
code). Once you're sure the memory is no longer referenced on the 
C heap, you can remove the root or range with GC.removeRoot and 
GC.removeRange.


More information about the Digitalmars-d mailing list