title: How can I use GDB with strace to find a memory leak?
body: <p>I have a C++ program which:</p>
  
  <ol>
  <li>Allocates memory (always the same amount)</li>
  <li>Should deallocate all that memory</li>
  <li>Repeats</li>
  </ol>
  
  <p>And I'm using the method I found <a href="https://www.google.com/amp/s/deathandthepenguinblog.wordpress.com/2015/08/15/poor-mans-memory-leak-detection-with-strace/amp/" rel="nofollow">here</a> 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.</p>
  
  <p>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.</p>
  
  <p>I can use GDB for this. What I thought to do was: run <code>strace</code> 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 <code>examine</code> GDB command (as strace prints the address at which memory is allocated, which I can use with GDB).</p>
  
  <p>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?</p>