|
From: reena <ree...@ya...> - 2007-03-22 06:15:08
|
Hi, I am using valgrind for checking the memory leaks in my application. I am running my application like this... valgrind --leak-check=full --log-file=out --tool=memcheck --show-reachable=yes ./myapplication When I do "ps v processId" the RSS(Resident segment size) value is increasing instead of being constant, that means some memory leaks are happening in the application. But valgrind is not able to find the leaks. Am I not giving the correct options to check the memory leak? Is there any other way to find out the memory leaks ? Please help me to fix the memory leak in my application. ps: Library is not statically built. In the valgrind user manual says that if the library is statically built it can not detect the memory leaks. Thanking you in advance. Regards Reena |
|
From: Paul P. <ppl...@gm...> - 2007-03-22 06:31:31
|
reena wrote:
>When I do "ps v processId" the RSS(Resident segment size) value is increasing
>instead of being constant, that means some memory leaks are happening in the
>application.
>
This statement is false.
Incresing RSS does not necessarily mean there is a memory leak.
One way I've seen this happen: mmap 1GB chunk, then touch 1
additional page every second. Your app RSS will grow at 4K/second
rate for 262144 seconds or just over 3 days.
Another way:
int main()
{
std::map<int, int> m;
for (size_t i = 0; i < 1000000000; ++i) {
m[i] = i; sleep(1);
for (int j = 0; j < i; ++j)
int x = m[j]; // keep "m" memory-resident
}
return 0; // destructor for "m" free()s all memory
}
Cheers,
|
|
From: reena <ree...@ya...> - 2007-03-22 09:10:31
|
I do have a map. But it is being used in a function scope. At the end of the function I am clearing the map. Is there any memory leak in basic STL containers , like map< string , vector<string> > which the valgrind doesnot show? |
|
From: Paul P. <ppl...@gm...> - 2007-03-22 13:09:04
|
reena wrote: >I do have a map. But it is being used in a function scope. At the end of the >function I am clearing the map. > >Is there any memory leak in basic STL containers , like map< string , >vector<string> > which the valgrind doesnot show? > See FAQ: http://valgrind.org/docs/manual/faq.html#faq.reports Regards, |
|
From: Nicholas N. <nj...@cs...> - 2007-03-22 09:14:26
|
On Thu, 22 Mar 2007, reena wrote: > I am using valgrind for checking the memory leaks in my application. > > I am running my application like this... > > valgrind --leak-check=full --log-file=out --tool=memcheck --show-reachable=yes > ./myapplication > > When I do "ps v processId" the RSS(Resident segment size) value is increasing > instead of being constant, that means some memory leaks are happening in the > application. But valgrind is not able to find the leaks. > > Am I not giving the correct options to check the memory leak? Is there any other > way to find out the memory leaks ? > > Please help me to fix the memory leak in my application. The tool "Massif" (--tool=massif) may be able to help you. It prints a graph showing memory usage over time, which can help detect the causes of slow memory increases that aren't strictly leaks. Nick |