garbage collector question

janderson askme at me.com
Tue Jul 24 09:27:11 PDT 2007


Hoenir wrote:
> Jarrett Billingsley schrieb:
>>> I'm wondering when and how to "disable" the GC and do the memory 
>>> mangement yourself?
>>
>> import std.gc;
>> std.gc.disable(); 
> 
> I don't want to disable it completely. I'm just wondering when it is 
> advantageous to do MM yourself and how to do it.

I haven't done this in D so I can't comment.

> How to prevent a variable from being deleted by the GC and such stuff.
> But thanks for your answer. :)

import std.gc;
//...
std.gc.disable();

//Do what ever non gc class allocation you want (you'll have to clean 
these up specifically yourself).

std.gc.enable();

You may want to do this for deterministic destruction, for optimization 
reason, or if you allocate from some sort of special memory.

-Joel


More information about the Digitalmars-d-learn mailing list