Memory percentage in top (linux)

5

1

Just wondering

(1) is the memory percentage in top for a process is relative to memory or relative to memory+swap?

(2) if it is the former, how can I get the latter? Vice versa.

(3) To determine if it is proper to run another executable, should I look into memory only or memory+swap? Or in which cases for example shall I consider which?

(4) Roughly speaking, to what extent the memory (or memory+swap) is used that I should better wait instead of submitting another job (of course it is not very small)?

Thanks and regards!

Tim

Posted 2009-10-01T22:32:17.217

Reputation: 12 647

Answers

3

Looking at an example:

Mem: 7928892k total, 7814100k used, 114792k free, 181504k buffers

Swap: 1020088k total, 92k used, 1019996k free, 2651664k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

11933 root 18 0 11.6g 3.4g 1.0g S 1 45.2 463:56.35 java

1) It seems %Mem is percent RES compared to memory without swap.

2) Just add Swap total to Mem Total and compare to RES.

3+4) Usually you'd take more facotrs into consideration than just memory (e.g. competition for CPU and IO), but only based on memory: If the new process does not fit into memory without swap it's better to wait. If it fits into memory + swap it will work but slower than the first option. Not sure what happens these days when it does not fit into memory+swap but it's almost ceratinly bad. Another factor to consider is that the OS will use un-used memory for caching so even if the second process fits execution may be slower compared to waiting for the first process to finish as less cache is available for both.

user12889

Posted 2009-10-01T22:32:17.217

Reputation: 1 743

Thanks! By the way, how to measure the usage of IO and therefore determine if I should add jobs with IO operations? – Tim – 2009-10-02T00:01:42.323

2

I had the same question "is the %MEM" relative to (RAM) ? or (RAM+SWAP) ?

until I found it at this source

“RES” is the memory consumed by the process in RAM, and “%MEM” expresses this value as a percentage of the total RAM available.

Accountant م

Posted 2009-10-01T22:32:17.217

Reputation: 121