GC.calloc(), then what?
eles via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jun 27 03:01:21 PDT 2014
On Friday, 27 June 2014 at 08:17:07 UTC, Ali Çehreli wrote:
> Thank you for your responses. I am partly enlightened. :p
>
> On 06/27/2014 12:34 AM, safety0ff wrote:
>
> > On Friday, 27 June 2014 at 07:03:28 UTC, Ali Çehreli wrote:
> But addRange doesn't seem to make sense for stdlib.malloc'ed
> memory, right? The reason is, that memory is not managed by the
> GC so there is no danger of losing that memory due to a
> collection anyway. It will go away only when I call stdlib.free.
It is not about that, but about the fact that this unmanaged
memory *might contain* references towards managed memory.
If you intend to place such references into this particular chunk
of memory, then you need to tell GC to scan the memory chunk for
references towards managed memory.
Otherwise, the GC might ignore this chunk of memory, find
elsewhere no references towards a managed object, delete the
managed object, then your pointer placed in the unmanaged memory
becomes dangling.
More information about the Digitalmars-d-learn
mailing list