How to release memory? (D2.0.30)

bearophile bearophileHUGS at lycos.com
Fri Jul 3 15:41:12 PDT 2009


AxelS:
>       void[] dat=new void[50_000_000]; // allocate 50 MByte of dummy-data

I am not sure, but the GC may scan that chunk of voids. If you need a raw block it may be better to work with an array of uint.


> Why can't the GC remove that data and how CAN I remove it?

If you really need to remove it, then you may not allocate it from the GC heap in the first place, and use the C heap, with a malloc and then free. But that requires a full manual management, and for safety it's then usually much better to put in such memory chunk only data that doesn't contain references managed by GC.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list