On Tue, Dec 9, 2008 at 9:42 AM, Jarrett Billingsley
<[EMAIL PROTECTED]> wrote:
> On Tue, Dec 9, 2008 at 9:16 AM, Daniel White <[EMAIL PROTECTED]> wrote:
>> Thanks for that reply. I wonder if extending automatic garbage
>> collection for malloced memory would be a good idea...
>
> That would be a bad idea.  Then how would you do manual memory
> management in the few cases that absolutely require it?
>
>>> Only stuff like dynamic
>>> arrays, AAs and new'ed stuff gets cleaned up by the GC.
>>
>> For the above types of allocating memory, is there a way to 'lock' a
>> variable and say to D, "don't free this memory until I allow you to",
>> and also for it to allow you to free it manually when/if need be?
>
> Yes, you can use std.gc.addRoot in Phobos (in D1), and GC.addRoot if
> you're using Tango (import tango.core.Memory) or D2 (import
> core.memory).

Oh yeah, and you can use 'delete' on arrays, classes, and structs
allocated on the heap, but oddly not with AAs.

Reply via email to