http://www.perlmonks.org?node_id=863660


in reply to Re^7: Memory leak question
in thread Memory leak question

Okay, I've now changed all given/when to if/elsif/else, and it has improved things, but it is still leaking (just not as fast).

I'd love to reduce the leakage even further. If I understand it correctly, one source of data leaks is if the value of a variable is actually a nested structure (so it has refs in it) and I set the value to something else, the old value is destroyed (assuming a refcount of 0), but any data referenced by it may not be automatically destroyed. Is that correct? I'm fairly sure that this happens, but I'm really not looking forward to a code audit of the thousands of lines of code to track this down.

Is there a good tool that I can use that will tell me every line number in the module where a variable was set to a new value and the old value was destroyed, but part of it hung around? Then, I could recursively destroy the old value before I created a new value (there's probably even a module to help me do this).

This, or any other suggestions would certainly be welcome. I'm afraid that in all the time I've been programming perl, I've never tried tracking down a memory leak, and I'm mainly just stumbling around in the dark I'm afraid.