参数用法
D:\>adb shell top --help
Toybox 0.8.6-android multicall binary (see toybox --help)
usage: top [-Hhbq] [-k FIELD,] [-o FIELD,] [-s SORT] [-n NUMBER] [-m LINES] [-d SECONDS] [-p PID,] [-u USER,]
Show process activity in real time.
-H Show threads
-h Usage graphs instead of text
-k Fallback sort FIELDS (default -S,-%CPU,-ETIME,-PID)
-o Show FIELDS (def PID,USER,PR,NI,VIRT,RES,SHR,S,%CPU,%MEM,TIME+,CMDLINE)
-O Add FIELDS (replacing PR,NI,VIRT,RES,SHR,S from default)
-s Sort by field number (1-X, default 9)
-b Batch mode (no tty)
-d Delay SECONDS between each cycle (default 3)
-m Maximum number of tasks to show
-n Exit after NUMBER iterations
-p Show these PIDs
-u Show these USERs
-q Quiet (no header lines)
Cursor UP/DOWN or LEFT/RIGHT to move list, SHIFT LEFT/RIGHT to change sort,
space to force update, R to reverse sort, Q to exit.
运行解析
参考https://www.cnblogs.com/flyingcode/p/13690223.html
# 任务:系统共有531个进程,2个处于运行状态,519个处于休眠状态,0个处于停止状态,0个处于僵死状态
Tasks: 531 total, 2 running, 529 sleeping, 0 stopped, 0 zombie
# 物理内存:总量、占用、空闲、缓存
Mem: 2726880K total, 2709404K used, 17476K free, 11008K buffers
# 交换分区:总量、占用、空闲、缓存
Swap: 1572860K total, 790408K used, 782452K free, 1010972K cached
# 可用内存 = Mem_free + Mem_buffers + Swap_cached
# 六核CPU、用户空间、改变过优先级的进程、内核空间、空闲、IO等待、硬中断、软中断、
600%cpu 3%user 0%nice 6%sys 587%idle 0%iow 4%irq 0%sirq 0%host
# 进程id、进程所有者、进程优先级、nice值、使用的虚拟内存、使用的未被换出的物理内存、共享内存、进程状态、CPU时间占用、使用的物理内存、使用的CPU时间总计、进程名
PID USER PR NI VIRT RES SHR S[%CPU] %MEM TIME+ ARGS
22059 root 20 0 12G 5.6M 3.7M R 2.0 0.2 0:00.24 top
15396 u0_a138 20 0 1.4G 178M 136M S 2.0 6.6 2:57.59 com.tencent.qqm+
15287 u0_a138 20 0 1.6G 201M 152M S 1.6 7.5 2:06.24 com.tencent.qqm+
1434 system 20 0 13G 6.1M 4.6M S 1.0 0.2 2:26.22 cnss_diag -q -f+
21160 root 20 0 0 0 0 I 0.6 0.0 0:04.24 [kworker/u12:3-+
21210 root 20 0 0 0 0 I 0.3 0.0 0:04.79 [kworker/u12:7-+
19273 root 20 0 0 0 0 I 0.3 0.0 0:12.77 [kworker/u12:6-+
5868 root 20 0 12G 8.1M 4.5M S 0.3 0.3 0:08.75 adbd --root_sec+
4912 system 20 0 16G 110M 71M S 0.3 4.1 8:17.83 com.qualcomm.qt+
4862 u0_a136 12 -8 33G 110M 69M S 0.3 4.1 0:36.40 com.baidu.appse+
2584 network_sta+ 20 0 16G 79M 53M S 0.3 2.9 0:16.89 com.android.net+
1087 wifi 20 0 13G 4.7M 4.2M S 0.3 0.1 0:30.42 android.hardwar+
1067 system 20 0 12G 4.9M 4.6M S 0.3 0.1 0:12.42 android.hardwar+
780 logd 30 10 12G 6.8M 3.7M S 0.3 0.2 17:27.74 logd
43 root 20 0 0 0 0 S 0.3 0.0 0:26.97 [rcuog/3]
进程状态STAT
常见有5种状态
- D,不可终端,uninterruptible sleep,通常是IO进程
- R,运行,runnable,在运行队列
- S,休眠,sleeping
- T,停止,traced(stopped)
- Z,僵死,zombie