Monks,

I am here to ask the same question asked two years ago in Memory Profiling. That question didn't get the kind of answer I'm looking for, but it's exactly the question I want to ask. Is there a tool that will tell me how a program uses the memory that it uses?

I know about Devel::Size, which is good for when you have a particular data structure that you want to watch. I also know about Memchmark, which will compare the memory used by different algorithms. I'm not asking about those, and I'm not asking how to find a memory leak.

What I want is something like Devel::DProf, but for memory. Imagine you receive a huge piece of code that's using too much memory. How do you tell what parts are using how much?

I'd like a tool that will list things that are using memory along with how much (max, mean, median). I want it to tell me how to find that structure in the code that I'm working on (by name, or by the line on which it's created).

If it's true that nothing like this exists, is it possible to create it? Could an XS module (or even a pure Perl module) somehow trap and track the creation and modification of every hash, array, or scalar?

Your wisdom will be greatly appreciated.


In reply to Profiling memory by kyle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.