Problem with delete[] in class destructor
Nathan Sidwell
nathan@codesourcery.com
Tue Mar 22 14:02:00 GMT 2005
Nicolas Wack wrote:
> I'm watching the memory consumption with 'top' (that's the reason for
> the call to sleep)
> However if I change the allocation to new float[] instead of new Test
> and then free it, it gets directly freed. (see attached file)
What do you mean by 'directly freed'?
>
> What's weird is that if I launch the original program a second time
> while the first already has supposedly freed its memory, it eats
> everything and bring my box to its knees, killing most of the processes
> that use memory (so I guess the memory is not freed at all).
the memory is not returned to the OS until the program terminates.
> Also, top tells me that the whole memory stays resident (which means it
> doesn't even return to the program's free memory pool, am I right?)
No.
This is not a gcc question, but a system/runtime library question. You
appear to be confused about heap allocation. Ask in a more suitable
forum (or search the web for 'malloc heap allocation' and similar terms).
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
More information about the Gcc-help
mailing list