How to destroy a big Array and free RAM

Giovanni Di Maria calimero22 at yahoo.it
Wed Dec 12 09:27:24 UTC 2018


On Wednesday, 12 December 2018 at 08:29:45 UTC, NX wrote:
> 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);
> }



Hi NX
Thank you very very much.
Giovanni


More information about the Digitalmars-d mailing list