help-gplusplus
[Top][All Lists]
Advanced

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

Re: Memory Leak??


From: nandakiran
Subject: Re: Memory Leak??
Date: Sat, 25 Aug 2007 02:05:32 -0000
User-agent: G2/1.0

after "deleting the nodes" if i allocate new memory using new
it takes in more memory , (not from the free pool). and the
memory blocks that i am allocating are all of the same
size, thus it should be possible to use it from the free pool...
after doing around 100,000 such operations, my total memory
allocated to the process is > 2GB, and then even after leaving it
on for quite some time, the memory is not de-allocated, and the
system becomes slow. The program i am writing does a lot's of
new's and deletes.

On Aug 24, 5:38 pm, red floyd <no.s...@here.dude> wrote:
> nandaki...@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]