1

Here on MacOS Catalina, when checking the memory usage of a process I see that the ps command shows a RSS value which is different from the memory usage shown in top:

$> ps e -o command,vsize,rss,%mem|grep "myapplication"|head -n 1
myapplication  4594896  51364  0.3

RSS -> 51364

top
PID    COMMAND       %CPU TIME    #TH             #WQ  #PORT MEM    
48106  myapplication 115.7        09:06.12 69/1   1    101   37M+

MEM -> 37M

Why this difference?

UPDATE:

Another example with IntelliJ process:

top -pid 357
PID  COMMAND      %CPU TIME     #TH   #WQ  #POR MEM    PURG CMPRS  PGRP PPID STATE    BOOSTS        %CPU_ME %CPU_OTHRS UID       FAULTS    COW   MSGSENT  MSGRECV  SYSBSD
357  idea         2.6  03:16:46 112   1    925  4906M  0B   1583M  357  1    sleeping  0[2884]      0.00000 0.00000    281451937 28337096  54627 8404446+ 2733245+ 156093159+

Top shows 4906M

ps aux
USER               PID  %CPU %MEM        VSZ    RSS   TT  STAT STARTED      TIME COMMAND

xxxxxxx            357   3.6 14.5 180050484 2430728   ??  S     1:44PM 196:48.70 /Applications/IntelliJ IDEA.app/Contents/MacOS/idea -psn_0_73746

ps shows RSS 2430728 (KB)

3
  • Can you add column labels to the top output? The meaning and the order of the columns change on different top versions. Which version of top are you using? On which OS?
    – andcoz
    Commented Mar 30, 2020 at 13:38
  • Added columns. Actually I'm using MacOs Catalina Commented Mar 30, 2020 at 13:40
  • There are many versions of top. Which one are you using in what operating system?
    – user10489
    Commented Jun 4, 2022 at 4:40

1 Answer 1

0

The most likely reason is ps is showing the resident memory while top is showing total or virtual memory (e.g. including swapped out and shared).

There are a lot of questions about this, including https://stackoverflow.com/questions/7880784/what-is-rss-and-vsz-in-linux-memory-management but that is why they are different values here.

2
  • I'm nos sure about that. Check the UPDATE. ps shows both VSZ and RSS, and both values are different from MEM in top Commented Apr 2, 2020 at 8:30
  • 1
    Top also supports directly showing RSS and VSZ. MEM is a different metric, so it should not be surprising it is different.
    – user10489
    Commented Jun 4, 2022 at 4:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .