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

I'm trying to figure out how much virtual memory my perl script is using. I've looked at node 498401 and node 502486, and it looks like Devel::Size is pretty close to what I want, but not quite.

Essentially, I'm using BSD::Resource to limit my script, and I'd like to know how much of these resources I'm actually using. The list of resources you can monitor with BSD::Resource::getrusage is smiler but actually very different from the list of resources you can limit. Specifically, you can limit virtual memory, but you can't look at your virtual memory usage. You can look at resident set size, but that doesn't seem to help me. (it always seems to say 0, even when I bust the vmem limit).

Devel::Size seems to work by walking through the code and totaling up the memory used. The system obviously has some simple value of my vmem size (otherwise, how does it know how to limit it?), so Devel::Size sounds inefficient for my purposes.

Anyone know a good way to get current vmem used?


Updated: This needs to work on Linux and OpenBSD.