Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am on a shared host and I am only allowed to use so much RAM. How can I find out how much I am currently using ? I know top and free and ps and some other tools, but they usually only display memory for the entire system, not user-specific. There is also this SF post which gives me the impression measuring memory usage is not a s trivial as it seems.

Maybe some esoteric ps switch plus some shell scripting ? I am reasonably sure I am not the first one with that issue, so there is probably a straight-forward solution, just can't seem to find it...

share|improve this question
Which form of VPS are you using, VM based, like vmware or xen ? or container based like Virtuozzo, OpenVZ or Linux V Servers ? – Dave Cheney Feb 25 '10 at 6:19
up vote 1 down vote accepted

The following should show the total resident set size (non-swapped physical memory) in KB.

ps uU username | awk '/^username/ { total += $6 } END { print total }'

If you need the virtual memory size, try:

ps uU username | awk '/^username/ { total += $5 } END { print total }'
share|improve this answer
I'd combine the two.... ps uU username| awk '/^username/ { vtotal += $5 } { rtotal += $6} END { print "R " rtotal " V " vtotal }' This is for a linux machine, ps flags and awk anchors will vary with different versions of ps – quadruplebucky Feb 26 '10 at 17:04
The OP mentioned free(1), which afaik is a Linux-ism. And the 'u' option without hyphen puts ps into BSD-style output mode, which is fairly consistent across platforms. (I tested on Linux, OS X, and FreeBSD.) But I do like the idea of producing combined output! – fission Feb 26 '10 at 17:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.