title: Find memory leaks caused by smart pointers
body: <p>Does anybody know a "technique" to discover memory leaks caused by smart pointers? I am currently working on a large project written in <strong>C++</strong> that heavily uses smart pointers with reference counting. Obviously we have some memory leaks caused by smart pointers, that are still referenced somewhere in the code, so that their memory does not get free'd. It's very hard to find the line of code with the "needless" reference, that causes the corresponding object not to be free'd (although it's not of use any longer).</p>
  
  <p>I found some advice in the web, that proposed to collect call stacks of the increment/decrement operations of the reference counter. This gives me a good hint, which piece of code has caused the reference counter to get increased or decreased.</p>
  
  <p>But what I need is some kind of algorithm that groups the corresponding "increase/decrease call stacks" together. After removing these pairs of call stacks, I hopefully have (at least) one "increase call stack" left over, that shows me the piece of code with the "needless" reference, that caused the corresponding object not to be freed. Now it will be no big deal to fix the leak!</p>
  
  <p>But has anybody an idea for an "algorithm" that does the grouping?</p>
  
  <p>Development takes place under <strong>Windows XP</strong>.</p>
  
  <p>(I hope someone understood, what I tried to explain ...)</p>
  
  <p>EDIt: I am talking about leaks caused by circular references.</p>