How to release memory? (D2.0.30)

Jarrett Billingsley jarrett.billingsley at gmail.com
Fri Jul 3 13:46:02 PDT 2009


On Fri, Jul 3, 2009 at 4:30 PM, AxelS<a_bothe at gmx.net> wrote:
> Hello everyone,
> I've got a problem with the following (very simple) code:
>
> void foo()
> {
>      void[] dat=new void[50_000_000]; // allocate 50 MByte of dummy-data
>      delete dat;
> }
>
> after I called foo() and watched the memory usage in the windows taskmanager, the program blowed up to 50 MBytes although I deleted the allocated memory...
>
> Why can't the GC remove that data and how CAN I remove it?
>
> Thanks in advance!

If you're using Tango or D2, you can use the GC.minimize() function
(in tango.core.Memory or core.memory) to release memory back to the
OS, but as BCS said, the amount of virtual memory is not really a
useful indicator anyway.


More information about the Digitalmars-d-learn mailing list