Deallocate array?

Matic Kukovec matic.kukovec at pametnidom.si
Fri May 10 01:44:14 PDT 2013


Thanks for the explanation guys.
Hope there will be improvements in D's GC in the future.

Also "delete temp_array" also works instead of 
"GC.free(temp_array.ptr)".
And you also need to call "GC.minimize()" after a 
delete/GC.free() if you want to shrink the memory use after the 
for loop:

         temp_array = new string[100000000];
	for(int i=0;i<100000000;i++)
	{
		temp_array[i] = "aaaaaaaaaaaaaaaaaaaaa";
	}
	delete temp_array; or GC.free(temp_array.ptr);
	temp_array = null;
	GC.minimize();  //releases the memory, works without this line

Is "delete" safe for this kind of use?

Thanks guys



More information about the Digitalmars-d-learn mailing list