help-gplusplus
[Top][All Lists]
Advanced

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

Re: Memory Leak??


From: Bernd Strieder
Subject: Re: Memory Leak??
Date: Mon, 27 Aug 2007 19:38:22 +0200
User-agent: KNode/0.10.4

Hello,

 nandakiran@gmail.com wrote:

> i tried valgrind in combination with the GLIBCXX_FORCE_NEW option.
> valgrind
> says i have freed all the the heap blocks, but still the memory
> occupied by the program
> doesn't reduce after doing the free.
> (i have increased the loop count from 10,000 to 100,000)
> here is the output:
> 
> [nandakiran@localhost temp]$ GLIBCXX_FORCE_NEW=1 valgrind ./test

I have similar output from valgrind, and the other runs are similar to
yours. I cannot find anything errorneous in your program.

On my system (openSuSE 10.2) memory is returned to the OS. When hanging
at the OK with loop count 10000 or 100000 the virtual memory of the
process is down to around 2MB as displayed by top.

With the loop count increased to 100000 my system starts swapping a
little bit (it has 512MB RAM), then it gets immediately responsive
again after swapping back a little, when hanging at the OK. So memory
must be returned to the OS. Maybe your system has so much RAM that the
OS decides to wait with actually taking its memory back, perhaps you
have to wait a while, or you have to increase the load towards the
limits of your system to see what you expect.

The allocation cache of libstc++ has been invented to help, your struct
makes it really hard to get help from the cache. It might be better to
replace the large buffer in the struct by a pointer, and handle
allocations of that buffer separately.

Bernd Strieder



reply via email to

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