Why won't top command show the right result?

2

You want to find the line 3427 1 root S 36964 124% 2% tmux -L l in the following screenshots of top command.

Why can tmux use more than 100 percent of memory? That is confusing...

Is this a bug of top command?

Mem: 28748K used, 1060K free, 0K shrd, 888K buff, 2452K cached
CPU:  15% usr  80% sys   0% nic   3% idle   0% io   0% irq   0% sirq
Load average: 6.47 4.22 2.96 3/78 14674
  PID  PPID USER     STAT   VSZ %MEM %CPU COMMAND
 1028     1 root     S     1536   5%   8% /usr/sbin/pppd pty /usr/sbin/pptp 10.
   81     2 root     SW       0   0%   4% [mtdblockd]
 1477     1 root     S     2616   9%   4% /usr/sbin/collectd -f 
 3427     1 root     S    36964 124%   2% tmux -L l 
 1561     1 root     S      752   3%   1% /usr/bin/luci-bwc -d 
  273     2 root     SW       0   0%   1% [usb-storage]
16393  6202 root     R     1368   5%   1% top 
  955     1 root     S     1420   5%   1% hostapd -P /var/run/wifi-phy0.pid -B 
14299 21514 root     R     1364   5%   1% top 
  345     1 root     S      788   3%   1% /sbin/hotplug2 --override --persisten
  949     2 root     SW       0   0%   1% [irq/39-b43]
 1619     1 root     S     1588   5%   0% /bin/sh /usr/bin/multiwan agent 
   67     2 root     SW       0   0%   0% [kswapd0]
 2540  1619 root     S     1496   5%   0% /bin/sh /usr/bin/multiwan agent 
  329     1 root     S     1372   5%   0% syslogd -C16 
 1826   345 root     S      784   3%   0% /sbin/hotplug2 --override --persisten
 8859  9515 root     S     3468  12%   0% vim python_pydiction.vim 
 1435     1 root     S N   2632   9%   0% smbd -D 
 1507  1506 root     S     2616   9%   0% /usr/sbin/collectd -f 
 1509  1506 root     S     2616   9%   0% /usr/sbin/collectd -f 

hugemeow

Posted 2012-09-27T16:00:41.370

Reputation: 1 819

Answers

5

It's a bug (or maybe a "feature") in busybox.

busybox top calculates %MEM as VSZ/MemTotal instead of RSS/MemTotal.

From https://unix.stackexchange.com/questions/44948/what-do-tops-mem-and-vsz-mean

Remember that VSZ is virtual memory, there's more of that than there is real memory.

RedGrittyBrick

Posted 2012-09-27T16:00:41.370

Reputation: 70 632

why busybox choose such a strange defination of memory size? – hugemeow – 2012-09-28T04:46:16.317

Wow, what an incredibly useless measurement! – David Schwartz – 2013-04-04T01:11:05.193

-1

It is possible if you have several processors.

Run

expr $(grep processor /proc/cpuinfo | cut -d: -f2 | tail -1) + 1

to see how many processors you have; this will find the processor lines, take the last number from it and increment it by one. The command grep searches processor, cut takes the part after : and tail takes the last line, expr is then used to increment 1 to it; you can run man followed by such command to figure out how a certain command is used.

mantra

Posted 2012-09-27T16:00:41.370

Reputation: 91

i see now that you are talking about memory... – mantra – 2012-09-27T17:27:09.907

1If you feel this answer is incorrect, it may be best to delete it. – bwDraco – 2012-09-27T21:10:15.637