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


in reply to Re^4: How can I free the memory of a XML::Simple-Object
in thread How can I free the memory of a XML::Simple-Object

Exist something like that for ActiveState-Perl?

See Devel::Size & Devel::Size::Report which does/can do something similar.

(I also just noticed Devel::SizeMe which I've no knowledge of, but comes from a good author, so would be worth investigating.)

I have to admit that I rarely resort to such tools for tracking memory leaks. Especially if threads are involved; I have my own method.

Basically this involves commenting out the bodies of suspect subroutines/methods -- but having them return plausibly 'good' values -- one at a time until I find which one is contributing to the leak. Then zeroing in from there.

With a program as complex as yours, it could be quite a laborious process, but I find it quicker than wading through reams of dumps. Especially where threads are involved which usually forces you to have to cross-relate data from several threads.

Working out which thread (type) is the cause is often quite easy. Just run an empty(ish) thread procedure for each type -- that again does just enough by way of modifying shared data or returning plausible values to allow the program as a whole to continue to run.

Once you've isolated the thread type involved, then apply the function-by-function mechanism as you would for a single threaded app.

It is actually harder to describe than do.

Good luck. (FV?)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong

  • Comment on Re^5: How can I free the memory of a XML::Simple-Object

Replies are listed 'Best First'.
Re^6: How can I free the memory of a XML::Simple-Object
by bulk88 (Priest) on Oct 27, 2012 at 18:43 UTC
    I have found that for CVs/subs Devel::Size will count entire package/class (GVs and every slice in the GV and all the shared key names of the stash and all sub stashes) that a CV is in for the size of a single sub. An XSUB with no optree comes in at a dozen KB. Be careful of what Devel::Size tells you.

      Indeed. For tracking absolute sizes, that can be a problem.

      But for the purposes of tracing leaks, whether they are optimistic or pessimistic for any particular construct, so long as the measurements are consistent, then the purpose is well served.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      RIP Neil Armstrong