How to determine memory usage?

K

kj

I want to determine how much memory my Perl program is using. If
possible, I'd like to measure the memory "high water mark", i.e.
the most memory used by the program at any point during its run.
If this is not possible, I'd settle for some instant memory read
that I can call periodically from within the program.

How should I do this?

Thanks!

kj
 
X

xhoster

kj said:
I want to determine how much memory my Perl program is using. If
possible, I'd like to measure the memory "high water mark", i.e.
the most memory used by the program at any point during its run.
If this is not possible, I'd settle for some instant memory read
that I can call periodically from within the program.

How should I do this?

On Linux I do this:

my $mem = (`ps -p $$ -o rss `)[1];

Gives size in kb. It is the resident size, so if you are worried being
partially swapped out, read the man page for ps and change rss to whatever
it should be.

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,183
Messages
2,570,965
Members
47,511
Latest member
svareza

Latest Threads

Top