2

I have a C++ program which:

  1. Allocates memory (always the same amount)
  2. Should deallocate all that memory
  3. 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?

user6245072
  • 2,051
  • 21
  • 34
  • 1
    have a look at valgrind and friends. The question as it is, is too broad, and more appropriated for stack overflow. If properly reworded, it could have a place here. – Rui F Ribeiro Oct 31 '16 at 12:47
  • @Rui F Ribeiro I'm on Android using Termux, Valgrind isn't an option. – user6245072 Oct 31 '16 at 13:42

1 Answers1

0

You might consider trying:

Jan Korous
  • 666
  • 4
  • 11