On Tue, 03 Mar 2015 19:50:03 +0100, Sönke Ludwig wrote:

Am 03.03.2015 um 13:29 schrieb Christian Ducrée:

I'm trying to free the memory after a large JSON object was created:

void createobject(){

 Json jso = Json.emptyObject();
 for(int i=0;i<1000000;i++){
    string str = format("Attrib #%d", i);
    jso[str] ="012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";

 }

}

I tried:

GC.collect();

and

destroy(jso);

to no avail.

destroy(jso); followed by GC.collect() should free the memory within
the GC pools. However, the GC just recycles the memory for later
allocations and doesn't give it back to the OS. At least that used to be
that case.

You could call createobject() within a loop to verify that the memory
really gets recycled, or if there is a genuine memory leak.

Thx. It works with destroy() and GC.collect(). Good to know that the memory is not returned to the OS but free for further allocation.