Sunday, January 23, 2011

top

Top is probably the most popular built-in tool on linux, and has been around for ages.  And busybox gives you top!

Have you ever noticed that sometimes your android device feels really sluggish and your cpu graph app (I use CpuNotify) is showing that your CPU is pegged?  I believe the most effective way to determine what's causing the phone to slow down is top.  Don't install apps that do similar stuff from the market - top will be more accurate and reliable.

Let's look at an example.  The other day my DX was just running dog slow and CpuNotify was telling me that the CPU was maxed out.  So I launch Terminal, run top, and scroll up:
# top -m 4 -n 3 -s cpu
User 83%, System 2%, IOW 4%, IRQ 0%
User 217 + Nice 0 + Sys 7 + Idle 75 + IOW 13 + IRQ 0 + SIRQ 0 = 312

  PID CPU% S  #THR     VSS     RSS PCY UID      Name
27769  80% S    21 236568K  69156K  bg app_74   com.dolphin.browser
18230   1% S    71 359916K  61852K  fg system   system_server
27888   1% R     1    848K    420K  fg root     top
18311   0% S    12 186360K  22416K  fg app_33   net.thinkindifferent.inputmethod.latin
[ snip ]
WTF!?!  What's my browser doing?  It turned out I made a classic mistake of going to a javascript intensive website and forgot to close the window.  Nine out of 10 times when your phone seems really sluggish, it's probably a runaway javascript that's still running on a browser window in the background.

So what do you do then?  Well you can bring the browser to the foreground again and close the offending tab/window.  Or you can just kill it from shell:
pkill -f browser

No comments:

Post a Comment