A question about moving GC

Walter Bright newshound at digitalmars.com
Thu Jun 8 16:28:20 PDT 2006


Stewart Gordon wrote:
> Walter Bright wrote:
>> Stewart Gordon wrote:
> <snip>
>>> Would it remain pinned indefinitely, until the C function exits, or 
>>> until the program explicitly unpins it by some means?
>>
>> It's pinned because it's on the stack, just like pointers on the stack 
>> for your D functions. The gc doesn't know the difference.
> 
> But what if the foreign code needs to hold onto the pointer for longer 
> than it can remain on the stack?

Have the D caller code keep a copy, or use addRoots to tell the gc where 
the foreign code is holding it.



More information about the Digitalmars-d-learn mailing list