Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Getting a memory dump

by okram (Monk)
on Nov 23, 2007 at 08:18 UTC ( [id://652524]=note: print w/replies, xml ) Need Help??


in reply to Getting a memory dump

I see this as an XY problem.. you have a problem with X (high memory), and decide to do Y (dump of all the data) to try and solve it... based on the false assumption that Y will actually help you solving X.

Many of the modules in the Devel:: category will help you "solving" Y: Devel::Peek will help you seeing the Dump() of every variable you use, showing you the exact data that Perl is using for it, such as showing you the value of the variable, the number of reference counts to it, the flags, etc.etc.

Instead, Devel::Size will tell you the exact memory allocated for each of the entitites (watch out for reference though:

my $ref = \$data; size($ref); # will give you the same size of $data my $ref = \$data; my $ref2 = \$ref; size($ref2); # will give you the s +ize of the reference itself

Somehow, I don't think that Devel::Peek or Devel::Size will help you much.

Now, off to solving X: have you tried using DProf and analysing where your code is spending its time? Are you using warnings/strict/diagnostic, and tried using hooks to the functions you think might cause the problem, via Hook::LexWrap? you can then wrap pieces of debugging code around any function, time it, check anything you want prior to and after the execution of any function..

Just my 0.01

Replies are listed 'Best First'.
Re^2: Getting a memory dump
by awy (Acolyte) on Nov 23, 2007 at 08:52 UTC
    You may be right to some extent in your XY supposition but nonetheless I think that a structured dump could be very helpful. This is especially the case because of the problem that I have of memory growth, where a (logical) diff between two snapshots could prove informative.

    The application in question has nearly 300 Perl modules and uses several hundred from CPAN. I do not really have much idea of the source of the problem. Yes, I may be able to narrow it down using DProf but memory use and CPU-use may not be all that well correlated.

    Interactive debugging is pretty much out as the application is single-threaded and has to operate in real time - delays of more than a few hundred milliseconds are fatal, although I can probably get into a sufficiently quiesced state for the few seconds that would be necessary to generate a dump

    I have read perlguts (twice) and other similar material but not found what I am looking for (yet). What I need is a way to walk the heap, finding every Perl variable. If I could work out how to do that then writing a dumper should not be too hard.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://652524]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2024-04-24 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found