Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'ps' and 'top' show different memory usage for single process

Tags:

memory

When I do 'ps -auxwww', it shows X using about 342M of memory.

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND 
[...] 
root      2009  1.0  5.1 342564 105012 tty7    Rs+  Oct08 469:24 X :0 
[...] 

However, 'top' shows about 1358M:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND 
[...] 
 2009 root      20   0 1358m 102m  14m S  0.3  5.1 469:24.27 X 
[...] 

Why, and which one is correct?

I've seen posts re 'top' and 'ps' "total memory used" being different (because of shared memory), but not why this would happen on a single process.

EDIT: it turns out that even none of the "ps -eo" options will give what top gives.


1 Answers

Top includes what's cached in buffers and whatnot. PS does not. If you want your actual usage by the application, use ps. If you want the total used by the application including what the system reserves for it .. use top

like image 184
Zak Avatar answered Oct 25 '25 15:10

Zak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!