Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

how can i get a comprehensive memory-dump ?

by tos (Deacon)
on Jun 07, 2004 at 10:28 UTC ( #361925=perlquestion: print w/replies, xml ) Need Help??

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

Hello friends,

within a (for my means) relative big Tk-project i notice a fast growing memory-utilisation at runtime. Since i delete no longer needed widgets and/or vars, i've expected a nearly constant amount of memory-use. Because this is not the case, i now want to find out which datastructures are responsible.

Could anybody give me a hint how to explore perls(Tks) memory-use ? I could imagine that there exists a possibility to dump it.

Thanks in advance and regards, tos

Is simplicity best or simply the easiest Martin L. Gore
  • Comment on how can i get a comprehensive memory-dump ?

Replies are listed 'Best First'.
Re: ho can i get a comprehensive memory-dump ?
by BrowserUk (Pope) on Jun 07, 2004 at 10:53 UTC

    You should probably read Debugging-Perl-memory-usage, but the bottom line is: It ain't easy!

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
Re: ho can i get a comprehensive memory-dump ?
by zentara (Archbishop) on Jun 07, 2004 at 15:11 UTC
    You will find in Tk, and other Perl programs that running "destroy" or "undef" on an object will not free all it's memory. If you post your code, we could find where this is occurring.

    Check out this linux memory leak monitor for a little Tk app I wrote to help you. What I did in my app, which had similar problems, is watch my memory usage with the above mentioned app, and strategically sprinkle my app with

    print 'my %hash-size = ', length Dump[\%hash], "\n";
    for each hash or array of objects which I had.

    The length of the Dump gives a pretty good indicator for the size of the hash or array. So I would just start clicking away, opening and closing, etc, and watch everything. You will see where it's happening.

    The hard part is NOT identifying where the memory increase occurs, but how to remedy it, without re-writting too much of your code.

    The general rule to follow is make widgets once, and learn to REUSE them, don't use create-destroy for bringing in new data.

    I'm not really a human, but I play one on earth. flash japh
Re: ho can i get a comprehensive memory-dump ?
by eserte (Deacon) on Jun 07, 2004 at 11:27 UTC
    Tk may still have some memory leaks. If you suspect some, you could use Devel::Leak to find leaking scalars. Make sure you run the latest Perl/Tk, preferably Tk 800.025, as Tk804.027 is fairly new and has some rewritten code which is not well-tested now.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://361925]
Approved by Paulster2
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2021-10-19 07:01 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (76 votes). Check out past polls.