221

Is there an option in top to show memory sizes in human readable format?

Example:

PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                            
3960 phil      20   0 1347280 383112  30316 S   0.0  9.5   6:59.45 firefox

It would be nicer to show RES as 374m (instead of 383112).

I'm currently using Arch Linux. Ubuntu seems to use human readable representations by default.

(I tried man top but could not find the option. Maybe I missed it.)

  • 2
    It depends how it was compiled it seems. Some distro (RHEL6) top -M seems to do the job but for archlinux check that https://bbs.archlinux.org/viewtopic.php?id=157103 – UnX Mar 31 '14 at 23:02
  • 5
    @slm this is not a dupe. "Human-readable" doesn't mean "always display in MB". "Human-readable" means select the scale (B/KB/MB/GB/TB) dynamically depending on the amount. – rustyx Oct 12 '19 at 14:28

1 Answers1

322

You can switch the memory unit by pressing e. E will select the memory unit in the top summary bar.

Use W to permanently write your configuration to /home/user/.toprc and see also ? for more configuration options.

smonff
  • 189
  • 8
Hauke Laging
  • 90,279
  • 9
    "Unknown command - try 'h' for help" – feeela Jan 13 '16 at 14:33
  • 6
    Ancient versions of top do not support command e. At least procps-ng version 3.3.9 supports it just fine. – Mikko Rantalainen Apr 13 '16 at 06:31
  • 4
    This is not a valid solution to the question. There is no option for human-readable units. Everything ends up using the same scale, which you need to manually change, which is very inconvenient. Compare to free -h which just chooses the correct units based on the magnitude of the value. – hackel Oct 17 '19 at 20:25
  • You are my hero! – clumsy Jan 09 '23 at 16:05