Remove All Ads from XDA

Memory/CPU Usage with adb top

186 posts
Thanks Meter: 2
By us1111, Senior Member on 18th August 2009, 02:49 PM
Post Reply Email Thread

I was curious why the Hero sometimes is blazing fast, and sometimes so incredible slow. That is why I decided to root the device to see what's going on in the device with top and other tools...

This is what is showing up, right after booting the device (sorted on memory usage and not showing kernel processes:

  PID CPU% S  #THR     VSS     RSS UID      Name
  123  12% S    12 239468K  43276K nobody
   67   5% S    50 212448K  35532K system   system_server
  119   0% S    14 140420K  24796K misc     android.process.acore
   36   0% S     1  72644K  21680K root     zygote
  121   0% S    18 120660K  21200K radio
  383   0% S    15 118140K  20328K app_40
  214   0% S    13 109376K  17696K app_3
  258   3% S     8 108124K  17636K app_5
  363   0% S     9 182892K  16784K app_25
  336   0% S     8  95792K  16384K app_22
  301   0% S     7 102784K  15392K app_12
  486   0% S     5 177860K  15364K app_78   org.koxx.pure_calendar
  271   0% S     8  95904K  15264K app_6
  346   0% S     8  97212K  15120K app_15
  495   0% S     6 110632K  15056K app_68
  460   0% S     6  96336K  14688K app_41
  477   0% S     6  95972K  14496K app_24
  390   0% S     6 102280K  13956K app_25
  176   0% S     7 100340K  13928K app_26
  443   0% S     5  94192K  13912K app_53
  448   0% S     6  96240K  13616K app_59   com.biggu.shopsavvy
  293   0% S     5  93400K  13492K app_9
  469   0% S     6 100004K  13488K system
  328   0% S     6  94660K  13316K app_17
  249   0% S     5  93420K  13280K app_80   com.socialnmobile.hangulkeyboard
  524   0% S     6  94024K  13248K app_48
  376   0% S     6  93772K  13204K app_32
  515   0% S     6  94324K  12620K app_13
  318   0% S     6  92960K  12460K app_21
  306   0% S     8  94976K  12140K app_19
  431   0% S     5  92016K  11708K app_73   com.rechild.advancedtaskkiller
  417   0% S     6  99156K  11684K app_45
   37   0% S     9  29752K   5360K media    /system/bin/mediaserver
  100   0% S     2   3124K   1156K wifi     /system/bin/wpa_supplicant
   35   0% S     9  11068K   1152K radio    /system/bin/rild
   38   0% S     1   1180K    740K bluetoot /system/bin/dbus-daemon
   41   0% S     1   1196K    580K compass  /system/bin/akm8973
  131   0% S     1    856K    428K dhcp     /system/bin/dhcpcd
   33   0% S     1    852K    400K root     /system/bin/vold
  538   4% R     1    916K    376K shell    top
  537   0% S     1    740K    332K shell    /system/bin/sh
   39   0% S     1    800K    308K root     /system/bin/installd
   32   0% S     1    808K    268K system   /system/bin/servicemanager
   34   0% S     1    668K    268K root     /system/bin/debuggerd
    1   0% S     1    292K    204K root     /init
   43   0% S     4   3332K    164K shell    /sbin/adbd
What I don't understand is why for example tunewiki has a memory intensive task in resident memory while i've never started it up. Also these processes I maybe (almost) never use , why on earth start them for me?:

Also the android calendar seems unnessesary because of the HTC calendar?

Why is the system keeping these processes in memory when they are not used? That seems like a waste of memory to me..

I know Android has a particular view on proces lifecycle management, however when I start a program, it may not use many CPU cycles but it does use and keep memory for itself...
18th August 2009, 08:12 PM |#2  
Thanks Meter: 6
I read somewhere that when a program/process is not used the memory is "unloaded" on the internal memory to free up some space, and reloaded when you use the program again.

But i can be wrong, I don't remember where I saw that.
18th August 2009, 08:26 PM |#3  
OP Senior Member
Thanks Meter: 2
Yeah... But top tells me otherwise.. I think the application stays resident (RSS) but CPU cycles are kept to a minimum. I think this is design when you leave an application with no service:

- Stop CPU cycles
- Leave memory footprint until needed otherwise
18th August 2009, 08:38 PM |#4  
Thanks Meter: 6
sorry my previous message was not clear (and my english is quite bad)

What I remember is that the process is still active (so you can see it with top) but the memory (RAM) is unloaded and saved on the internal storage. When you start the process again it just reload the data to the RAM
19th August 2009, 11:04 AM |#5  
kiz's Avatar
Flag Edinburgh
Thanks Meter: 0
Why are you worried about memory usage? These days many operating systems pre-fetch apps so they load quicker. I imagine Android has just selected certain apps to pre-fetch. Remember, empty RAM is wasted RAM!

I would be more concerned with cpu cycles if I were you.
19th August 2009, 11:23 AM |#6  
OP Senior Member
Thanks Meter: 2
Originally Posted by kiz

Why are you worried about memory usage? These days many operating systems pre-fetch apps so they load quicker. I imagine Android has just selected certain apps to pre-fetch. Remember, empty RAM is wasted RAM!

I would be more concerned with cpu cycles if I were you.

pre-fetching apps is somewhat different than keeping programs in RSS. What I see in top is that programs stay in resident memory, which is not easely reclaimable. It then will take (a lot) of CPU cycles to free up and re-fill this memory, so there is a relation...

What I do see in practice is that android is sometimes slow and sometimes quite fast, without changing anything obvious. I was/am looking for a reason for this symptom.

That is why I rooted the thing to be able to see some low level system stat's. In top I see that a lot of programs stay in resident memory which is normaly not good in linux/unix land..
If there is an detail design of how Android does this, I would really like to see it (and hope that i'll understand it). By the way, I have seen the presentation of process lifecycle management, but this describes inactive applications as "saved" which i presume is not keeping it in memory.

And indeed emtpty ram will probably never happen with a linux kernel because of caching an buffering...
19th August 2009, 12:42 PM |#7  
Junior Member
Thanks Meter: 0
just use taskiller app all the time
19th August 2009, 12:51 PM |#8  
OP Senior Member
Thanks Meter: 2
Originally Posted by darkpython666

just use taskiller app all the time

Hmm.. i would like to approach it a more scientific way.. A good OS should not need you to do that..

As I can see it, tuning could be done in the init.rc scripts and in particular this section which adresses the out of memory (oom) killer:

# Define the oom_adj values for the classes of processes that can be
# killed by the kernel.  These are used in ActivityManagerService.
    setprop ro.FOREGROUND_APP_ADJ 0
    setprop ro.VISIBLE_APP_ADJ 1
    setprop ro.SECONDARY_SERVER_ADJ 2
    setprop ro.HOME_APP_ADJ 4
    setprop ro.HIDDEN_APP_MIN_ADJ 7
    setprop ro.CONTENT_PROVIDER_ADJ 14
    setprop ro.EMPTY_APP_ADJ 15

# Define the memory thresholds at which the above process classes will
# be killed.  These numbers are in pages (4k).
    setprop ro.FOREGROUND_APP_MEM 1536
    setprop ro.VISIBLE_APP_MEM 2048
    setprop ro.SECONDARY_SERVER_MEM 4096
    setprop ro.HOME_APP_MEM 4096
    setprop ro.HIDDEN_APP_MEM 5120
    setprop ro.CONTENT_PROVIDER_MEM 5632
    setprop ro.EMPTY_APP_MEM 6144

# Write value must be consistent with the above properties.
# Note that the driver only supports 6 slots, so we have HOME_APP at the
# same memory level as services.
    write /sys/module/lowmemorykiller/parameters/adj 0,1,2,7,14,15

    write /proc/sys/vm/overcommit_memory 1
    write /proc/sys/vm/min_free_order_shift 4
    write /sys/module/lowmemorykiller/parameters/minfree 1536,2048,4096,5120,563

    # Set init its forked children's oom_adj.
    write /proc/1/oom_adj -16
29th January 2010, 12:31 AM |#9  
Junior Member
Thanks Meter: 0
I'm wondering the same thing lately as I try to speed up my Droid. With OSMonitor's new cpu graph in the notification area, I noticed my cpu usage was very high a good deal of the time. So I rebooted and watched it stay at 99% for a while. I went to watch the processes and it was tunewiki, mixzing and camera ( taking up all the cpu. I hadn't started any of them. Tunewiki was over 90% for several minutes. I would understand an initial scan, but it's been installed for over 24 hours so I don't know what the hell it could still be doing. I have about 14GB of music on the SD right now, so I'm wondering if it has to scan through that on every reboot.
29th January 2010, 03:09 AM |#10  
BlueHawk's Avatar
Senior Member
Flag Toronto
Thanks Meter: 61
I wouldn't get too hung up about memory usage. The most important thing that will chew battery and slow down your device is CPU. And that is going to be up to the app developer and how they design things. Ideally, you want to write your program so that it doesn't run all the time - that is, it has a sleep state. If all your apps play nice and sleep when they are put in the background, your OS can then go into a hibernate mode when not being used by you (not tapping on the keyboard or doing other things interactively with it). This saves battery because hibernate allows halting the CPU cycles (when the CPU is awake, when it is not doing anything related to any app, it will be executing the equivalent of a NOP, which still chews battery). Also, if you have programs that don't allow a sleep (or rarely) , other apps get starved of cycles, hence you see a slow down.

As for your question as to why you have other processes at boot, some apps are written to start at boot. That was how the developer intended it to work. And some of these things, you don't want to kill. Some of these are even part of the core Android or HTC Sense, and if you kill it, Android will die an ugly death - try killing HTC Checkin and see how your Hero takes that!

If your system needs RAM, it will start swapping inactive app data out of active memory onto the swap. Use "free" in busybox, to gauge if anything got moved out to swap.
20th June 2011, 11:13 AM |#11  
mjehan's Avatar
Senior Member
Flag Erlangen
Thanks Meter: 47
what is this "top" process ?
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes