How to destroy a big Array and free RAM

NX nightmarex1337 at hotmail.com
Wed Dec 12 08:29:45 UTC 2018


On Wednesday, 12 December 2018 at 08:14:57 UTC, Giovanni Di Maria 
wrote:
> How to delete an array and to free RAM
>
> After to have filled of data i measure the RAM with an utility 
> (for example Wise Memory Optimizer).
>
> Then i try to destroy the array in many modes, but the free RAM 
> is still the same.

Destroying and free-ing are not the same thing. Since D is a 
garbage collected language you probably want to do something like 
this:

import std.stdio;
import core.memory;

void main()
{
     long[][] array = new long[][](1024, 1024);
     writeln(GC.stats);
     destroy(array);
     GC.collect();	// Mark & Sweep
     GC.minimize();	// Free unused memory
     writeln(GC.stats);
}


More information about the Digitalmars-d mailing list