Top command on Android

What is top command?

The “top” command from Linux is a very handy tool for getting various info for running processes and available system resources. It gives you process name (Name), priority (PR), State (S), Process ID (PID), Percentage of CPU (CPU%) that this process uses, number of threads in the process (#THR), User ID (UID), Policy (PCY) , VSS and RSS memory.


Usage: top [ -m max_procs ] [ -n iterations ] [ -d delay ] [ -s sort_column ] [ -t ] [ -h ]
    -m num  Maximum number of processes to display.
    -n num  Updates to show before exiting.
    -d num  Seconds to wait between updates.
    -s col  Column to sort by (cpu,vss,rss,thr).
    -t      Show threads instead of processes.
    -h      Display this help screen.


How does it do it?

as in ordinary linux os.

  • general info: /proc/stat
  • process stats (state, utime, stime, vss, rss, priority): /proc/{process}/stat
  • process name:  /proc/{process}/cmdline
  • process uid & gid: /proc/{process}/status
  • process thread info: /proc/{process}/task/{thread}/…

Source code: