help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Leak??


From: red floyd
Subject: Re: Memory Leak??
Date: Fri, 24 Aug 2007 15:38:23 -0700
User-agent: Thunderbird 2.0.0.6 (Windows/20070728)

nandakiran@gmail.com wrote:
What makes you think you have a memory leak?- Hide quoted text -

- Show quoted text -
 > when i run  ksysguard. it shows that my memory is not de-allocated,
and around 40mb of memory
is still being allocated to my program (after reaching printf("ok")).
whereas, In the first case, after the end of delete's , only 4 mb of
memory
is allocated to my program.


So, that simply means the memory is allocated to the process. In other words, to satisfy all 10000 of those extra new's, it had to get a pile of memory from the OS. The delete's return it to the free store (it's *NOT* leaked), but the process does not return it to the OS. It's not required to, nor should it, since the allocator doesn't know if you're going to allocate more memory or not.

So the memory is freed (deleted), but just not returned to the OS -- it's still allocated to your process' memory space.

This is why using tools like top or ksysguard to detect leaks is fairly useless. Use valgrind instead.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]