Question

I would like to consult this problem

I have a program that I'm running that in the long run, its memory keep increasing up until all resource are exhausted and of course it crashes (takes several of days to reach critical size).

what I've done till now, is using Valgrind, found all the memory leaks and fixed them, but now I still have a small memory leak that is caused by heap increasing size, for this I used Valgrind massif tool.

the problem is that when I use massif, it cannot run for too long time, and it causes the application to crash after several hours. I've tried to find the memory leak for an one hour run, the problem that the minimum threshold cannot be lowered from 1% of memory, and after 1 hour I can see memory increase but it still small compare to the rest of the application. so I can see part that takes more memory, but I cannot see which parts

example in valgrind output file:
->03.11% (4,377,152B) in 28 places, all below massif's threshold (01.00%)

any thoughts?

Was it helpful?

Solution

Use google perftools.
You can link your program or even LD_PRELOAD the library in and it will profile your heap use generating snapshots, it won't take much of your performance out, when you see that the heap is already too big you can stop it and get a graph of where the memory is spent.

EDIT: tutorial here

Example: enter image description here

OTHER TIPS

Have you used valgrind with -leak-check--full? What are you using that could use memory? Have you deleted every new?

Maybe you crashed because you are allocating a huge memory space at once (happened to me before) and valgrind can't see it sometime.

It is "strange" anyway, tell us the answer if you find it !

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top