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

Answer: Is there any way to report mem usage?

by ryan (Pilgrim)
on Feb 20, 2001 at 14:01 UTC ( #59623=categorized answer: print w/replies, xml ) Need Help??

Q&A > debugging > Is there any way to report mem usage? - Answer contributed by ryan

If you are meaning the memory used by your program then there was talk of this here

If you are talking of the system in general then I might do something crude like this with the /proc file system:

$meminfo=`cat /proc/meminfo | grep "^Mem: "`; $meminfo =~ s/^Mem\:\W+//; ($total, $used, $free, $shared, $buffered, $cached) = split(/\W+/,$mem +info,6);

Then you have the 2nd line of /proc/meminfo in 6 variables and can write them out to whatever log you want. There are modules to deal with /proc but I can't find anything to return memory information, only individual process attributes.

I'm not fantastic at coding, just thought I'd give it a try, I'm sure there is a quicker way - but that is how I would do it with my current knowledge :) I guess this could break if the format of /proc/meminfo was ever changed.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[erix]: o/
[erix]: I'm a bit stuck with regex capturing. Anyone wants to ahve a look at my [erix://pad | scratchpad ? (it's the little test program at the top there)]
[erix]: hm [erix://pad]
[erix]: pad::/erix
[erix]: erix's scratchpad
[erix]: ah! ;)
[erix]: I'm trying to capture some detail from user input I'm pretty sure I have done this before

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2018-01-19 08:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (216 votes). Check out past polls.

    Notices?