Linux – Find out the total memory allocated for a particular process in Ubuntu

linuxmemoryprocess

How can I find out the total memory allocated for a particular process in Ubuntu?

Best Answer

Try:

pidof bash | xargs ps -o rss,sz,vsz

To find the memory usage of your current bash shell (assuming you're using bash). Change bash to whatever you're investigating. If you're after one specific process, simply use on it's own:

ps -o rss,sz,vsz <process id>

From the man page:

RSS: resident set size, the non-swapped physical memory that a task has used (in kiloBytes).

SZ: size in physical pages of the core image of the process. This includes text, data, and stack space.

VSZ: virtual memory size of the process in KiB (1024-byte units).

The man page for ps will list all the possible arguments to the -o option (there are quite a few to choose from). Instead of -o rss,sz you could use the BSD style v option (no dash) which shows an alternative memory layout.

Related Question