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

  • 1
    Have you tried ps -aefl and looked at the SZ column? – mdpc Aug 22 '14 at 5:30
  • 2
    What do you mean by “find out the memory allocated”? Do you want to know how much memory the process is using? – Gilles 'SO- stop being evil' Aug 22 '14 at 22:03


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.

  • Thanks gareth... Are you saying that SZ is the memory allocated for that process? – Anjali Aug 22 '14 at 6:30
  • 4
    There's a good QA here that explains the relationship between RSS, SZ and VSZ. – garethTheRed Aug 22 '14 at 7:03

You can use pmap which shows the memory map of a process:

pmap -p pid

For more information about it see the man page man pmap or have a look at pmap(1): report memory map of process - Linux man page.


how to find out the total memory allocated for a particular process in ubuntu?

You don't define what is the memory allocated for a process, and actually that is a pretty complex question (what about shared memory mappings - see mmap(2) for details; what about POSIX shared memory - see shm_overview(7) for more; what about some pages in the page cache used for opened files; etc...)

You could use the /proc/ file system (which BTW is used by ps, pmap, top, htop etc....). Read proc(5) for more. In particular for process of pid 1234 you could use /proc/1234/status, /proc/1234/statm, /proc/1234/maps etc... They are all textual pseudo-files (a bit like pipes) that you can see with cat (or read sequentially inside some program). BTW, from inside a program you might use /proc/self (which is a pseudo symlink), e.g. read sequentially /proc/self/status etc...

See also LinuxAteMyRam.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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