see a program's memory use

How much memory a program really uses, and which programs use the most.

  • processes
  • system

Steps

  1. ps aux --sort=-rss | head

    the programs using the most memory, first (Linux)

  2. ps -o pid,rss,vsz,cmd -p PID

    one program: RSS is the memory it really holds, in KB

  3. grep -E 'VmRSS|VmSwap' /proc/PID/status

    its memory and its swap (Linux)

  4. pmap -x PID | tail -1

    the total of every part of its memory

  5. smem -k -P NAME

    memory shared counted fairly, by name (smem)

  6. free -h

    the whole machine's memory

Notes

  • Put the program's number in place of PID: pgrep -l NAME finds it.
  • macOS: ps -o pid,rss,command -p PID and Activity Monitor.

Commands used

  • ps
  • pmap
  • free
  • top

Each has a page in lore: lore ps opens it.