www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - How to destroy a big Array and free RAM

reply Giovanni Di Maria <calimero22 yahoo.it> writes:
How to delete an array and to free RAM

Hi. Can you help me please?
I have tried many experiments but without success.
I have a big array of arrays (matrix[][]).

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.

Can you help me please?
Thank you very much
Giovanni Di Maria
Dec 12 2018
parent reply NX <nightmarex1337 hotmail.com> writes:
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); }
Dec 12 2018
parent Giovanni Di Maria <calimero22 yahoo.it> writes:
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
Dec 12 2018