delete a dynamic array
tsalm
tsalm at free.fr
Sun Oct 12 02:49:03 PDT 2008
>> /* ------------------------------- */
>> import tango.time.Time;
>> import tango.io.Stdout;
>> import tango.stdc.stdio;
>> import tango.core.Memory;
>> void main()
>> {
>> // Create a big array
>> int[] t = new int[100000000];
>> // delete the array
>> t = null;
>> // Clean the memory
>> GC.collect();
>> GC.minimize();
>> // No, it's not free :-(
>> Stdout("Now, the memory must be free...")();getchar;
>> }
>> /* ------------------------------- */
>> How can I totally clear this array of the memory ?
> delete t;
It doesn't work too :-(
Here is what I do (phobos version, tested on dmd.2.019) :
*/ -------------------------------- */
// import tango.io.Stdout;
// import tango.stdc.stdio;
import std.stdio;
// import tango.core.Memory;
import GC = std.gc ;
void main()
{
// Create a big array
int[] t = new int[100000000];
// delete the array
delete t;
// Clean the memory
// GC.collect();
GC.fullCollect;
GC.minimize();
// No, it's not free :-(
writeln("Now, the memory must be free...");getchar;
}
More information about the Digitalmars-d-learn
mailing list