I have a C++ program which:
- Allocates memory (always the same amount)
- Should deallocate all that memory
- Repeats
And I'm using the method I found here to know if all the memory is deallocated properly. But it turns out that every 15 or so iteration my program requests more memory, which in theory shouldn't happen.
I want to know where and why is that memory requested, and what isn't being deallocated which causes the program to request more and more memory as time passes.
I can use GDB for this. What I thought to do was: run strace
with my program for a little. Interrupt the program and hook GDB to it by passing it's process number to GDB. And then (maybe?) try finding out what's going on by using (maybe?) the examine
GDB command (as strace prints the address at which memory is allocated, which I can use with GDB).
However, I am not sure this is the way to go, and I'm also not completely sure on how to stop my program whitout stopping its process. Any help?