http://qs1969.pair.com?node_id=1178366

xjd925z has asked for the wisdom of the Perl Monks concerning the following question:

How do you debug a script that - you've been told - is causing memory leaks?

Replies are listed 'Best First'.
Re: memory leak
by Athanasius (Archbishop) on Dec 22, 2016 at 14:28 UTC
Re: memory leak
by kschwab (Vicar) on Dec 22, 2016 at 14:09 UTC

    Devel::Size might be useful, especially if you have some idea which variables/objects/data structures might be suspect.

    Do you know why you've been told it's leaking? Assuming this is on a unix/linux box, can you try "top -p your_process_pid" and see if the VIRT figure grows in an unbounded way over time?

    Edit: Didn't find it earlier, due to the odd name, but Devel::Gladiator looks promising. It walks everything, and gives an example of how to spot new entries.
Re: memory leak
by eyepopslikeamosquito (Archbishop) on Dec 22, 2016 at 20:14 UTC
Re: memory leak
by Marshall (Canon) on Dec 22, 2016 at 22:31 UTC
    How do you debug a script that - you've been told - is causing memory leaks?

    A very important step in this is reproducing the problem. If this is a good defect (bug) report, then it will explain in detail what the user did to cause the problem and what they did to measure the problem.

    Your first step is to make what the user saw happen, happen for you on your test system. Then once you can make it happen, try to make as short a case as possible that will make the problem happen as frequently as possible and as easily as possible.

    I have worked on some problem reports full-time for a week to make the problem report into something that the Developer cannot ignore...Run program A and this causes problem X, measured by metric Y. Repeatability is a key step to figuring out a solution.