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

Esteemed Monks,

I have a rather large Perl/Tk application on Win32 which intermittently mangles the generation of an XML file. I don't know why this is happening, but I want to monitor memory usage during the process to see if that is causing it.

Is their a module that will show me the available memory in the system and the memory being used by my process?

jdtoronto

  • Comment on Monitoring memory usage in Perl program

Replies are listed 'Best First'.
Re: Monitoring memory usage in Perl program
by BrowserUk (Patriarch) on Oct 16, 2005 at 14:06 UTC

    Win32::Process::Info


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
Re: Monitoring memory usage in Perl program
by ides (Deacon) on Oct 16, 2005 at 15:23 UTC
    I'm curious why you are wanting to monitor the memory usage. I can't fathom a way that low or high memory usage would mangle your file, it's 99.999% more likely a subtle bug in the code.

    Frank Wiles <frank@wiles.org>
    http://www.wiles.org

      Yes, ides, I am inclined to agree. There is something VERY subtle going on. On some machines I can have the problem occur regularly on others I never see it at all. What happens is that I build two base64 encoded sound files as scalars in memory that could be 4 or 5 megs, then I combine these into a single scalar using HTML::Template as an XML templating engine and then I produce a URL-encoded version of the scalar before it is uploaded to a service bureau site. I suspect that I am ending up with too many copies of these big files in memory. But I am not sure, it would ease my mind if I can watch what is happening.

      jdtoronto

Re: Monitoring memory usage in Perl program
by sgifford (Prior) on Oct 16, 2005 at 16:31 UTC
Re: Monitoring memory usage in Perl program
by zentara (Cardinal) on Oct 17, 2005 at 12:30 UTC
    Well this is for linux, but it could give you an idea on how to use Win32::ProcessInfo. It just displays the memory usage in a little label in the corner of your screen. I always use it to test my big programs for memory gains. linux memory leak monitor

    I'm not really a human, but I play one on earth. flash japh