I am trying to read (and understand) the CPU usage provided by the top command in my Samsung Galaxy S7.
From another post here I can see the explanation of the top command with the output that this person is getting.
However, when I go inside my Samsung using adb shell and I cal the top command, what I get is different from what the other used posted.
Am I doing something different/wrong?
If not, how do I read this output from top??
The output from the user on the other post has this:
User 5%, system 15%, IOW 0%, IRQ 0%
User 5 + Nice 0 + Sys 14 + Idle 73 + IOW 0 + IRQ 0 + SIRQ 0 = 92
PID CPU% S #THR VSS RSS UID Name
213 11% R 1 900K 340K app_16 top
However, the output from my top gives me something like that:
Tasks: 371 total, 7 running, 359 sleeping, 0 stopped, 0 zombie
Mem: 3618604k total, 3545056k used, 73548k free, 118980k buffers
Swap: 2097148k total, 894520k used, 1202628k free, 1441660k cached
800%cpu 9%user 0%nice 11%sys 780%idle 0%iow 0%irq 0%sirq 0%host
Basically, I cannot see the row
User 5%, system 15%, IOW 0%, IRQ 0%
which seems to be the key to understand the CPU usage.
Not really sure why, but "top" command is not longer accepting params on Android 8
Related
I have a repeating job scheduled using JobScheduler API in Android 7.0.
Please help me understand the following output of command:
adb shell dumpsys jobscheduler
u0a66 / < pkg >: 58x pending 5% 52x active
58 pending jobs, and 5 % (of total 52 running tasks) completed. /* 5 percent completed jobs id are stored in CompletedJobs queue to track */
adb shell dumpsys jobscheduler >> output.txt
gedit output.txt //read the complete output to get concepts
Commonly x is used to represent a number (how frequently).
I have an output something as below:
Current stats at 2017-07-25-01-42-38 (-5m30s657ms) over +5m30s657ms:
1000 / android: 2x pending 1x active
u0a14 / com.google.android.gms: 1x pending 1% 1x active-top
u0a66 / com.google.android.apps.photos: 3x pending 1x active
Max concurrency: 3 total, 1 foreground
Syntax:
/*<Uid> <reference> <app_name>: <% completed> <pending_jobs_count> <% completed>
<active_jobs_count> <status_that_tells_if_active_job_is_at_top_of_queue> */
It is a general understanding of how it should be. I can't provide you the link, so I am also not 100% certain. I just shared you my view.
JobScheduler is to effectively maintain the concurrency (from thread level -- called jobs). Even for the same program, there can be multiple processes (eg, service can start from the different process), and several threads. Ultimately these all threads are put in ThreadPoolExecuter and their operations are scheduled.
The job can be in pending, active and active-top state.
The u0a66 / package.name: 58x pending 5% 52x active line means that during that specified duration the package.name has 58 jobs in the pending state (which have been pending for less than 0.5% of the duration total), 52 jobs in the active state (which have been active for 5% of the duration total) and 0 jobs in the active-top state.
I am doing some memory testing and I came across procstats in my research - before I start using it though I would like to fully understand everything before I start relying on its data.
Here is a condensed file of what I am trying to work with:
CURRENT STATS:
* com.samsung.android.providers.context / u0a6:
TOTAL: 100% (4.2MB-4.2MB-4.2MB/3.3MB-3.3MB-3.3MB over 1)
Service: 100% (4.2MB-4.2MB-4.2MB/3.3MB-3.3MB-3.3MB over 1)
* com.sec.android.inputmethod / 1000:
TOTAL: 100% (28MB-28MB-28MB/27MB-27MB-27MB over 2)
Imp Fg: 100% (28MB-28MB-28MB/27MB-27MB-27MB over 2)
* com.google.android.googlequicksearchbox / u0a54:
TOTAL: 0.05%
Imp Bg: 0.05%
(Cached): 100% (4.8MB-4.9MB-5.0MB/3.2MB-3.3MB-3.4MB over 2)
* com.google.android.talk / u0a98:
TOTAL: 0.03%
Imp Bg: 0.03%
Receiver: 0.00%
(Cached): 100% (8.8MB-8.8MB-8.8MB/7.4MB-7.4MB-7.4MB over 2)
(Home): 100% (20MB-20MB-20MB/18MB-18MB-18MB over 1)
Run time Stats:
SOff/Norm: +24m36s393ms (running)
TOTAL: +24m36s393ms
Start time: 2014-12-08 14:22:50
Total elapsed time: +24m36s508ms (partial) libdvm.so chromeview
Here are the questions:
What does "over 1" / "over 2" mean?
What is the difference between Service, Imp Bg, Receiver, and Imp Fg?
Why doesn't every total list the RAM usage (com.google.android.talk for example)
What does 100% mean and what does .03% mean?
Why do only some have (Cached)/(Home)?
What does 100% (Cached)/(Home) mean?
What does "(partial) libdvm.so chromeview" mean?
Lastly, am I correct in assuming that (4.8MB-4.9MB-5.0MB/3.2MB-3.3MB-3.4MB) is (low pss - avg pss - high pss / low uss - avg uss - high uss)?
If anyone could shed any light on this is would be greatly appreciated. Thanks.
As a heads up, I've already read these two links.... android-developers.blogspot.com/2014/01/ and android.googlesource.com/platform/frameworks/base/+/master/core/ .... and a few other pages - these are still the questions that I have left over. Can anyone go into detail about all 8 questions?
Edit
So I have been trying to compare numbers between procstats and meminfo and it really only adds more questions.
Here is an excerpt from procstats
CURRENT STATS:
* com.dropbox.android:crash_uploader / u0a87:
TOTAL: 100% (4.8MB-4.8MB-4.9MB/3.9MB-3.9MB-3.9MB over 6)
Service: 100% (4.8MB-4.8MB-4.9MB/3.9MB-3.9MB-3.9MB over 6)
* com.mobileposse.client / u0a22:
TOTAL: 0.16%
Service: 0.13%
Receiver: 0.03%
(Cached): 98% (7.2MB-8.4MB-9.3MB/6.1MB-7.2MB-8.1MB over 7)
* com.android.chrome / u0a79:
TOTAL: 0.01%
Receiver: 0.01%
(Cached): 86% (5.2MB-5.2MB-5.4MB/4.4MB-4.4MB-4.4MB over 3)
Here is an excerpt from meminfo
Total PSS by process:
5524 kB: com.android.chrome (pid 7334)
4969 kB: com.dropbox.android:crash_uploader (pid 5617)
Now dropbox makes sense, and I would say 80% of the processes follow dropbox's lead with having matching numbers between meminfo and pocstats. What I don't get - why does chrome not have any totals in the procstats but is listed in the meminfo and why does mobileposse have higher stats than chrome in the procstats but is not listed in the meminfo?
Take a look to the sources linked by Alex P. You can find the answer to some questions there:
What does "over 1" / "over 2" mean?
That is the number of samples taken.
What is the difference between Service, Imp Bg, Receiver, and Imp Fg?
They are different states (Imp Bg means Important Background, and Imp Fg Important Foreground)
Why doesn't every total list the RAM usage (com.google.android.talk for example)
What does 100% mean and what does .03% mean?
% of the time that these apps have been running.
Why do only some have (Cached)/(Home)?
What does 100% (Cached)/(Home) mean?
What does "(partial) libdvm.so chromeview" mean?
Lastly, am I correct in assuming that (4.8MB-4.9MB-5.0MB/3.2MB-3.3MB-3.4MB) is (low pss - avg pss - high pss / low uss - avg uss - high uss)?
Yes, you are corrent, the documentation describes them as minPss-avgPss-maxPss / minUss-avgUss-maxUss
The percentages tell you how much of the overall time each process has spent in various key states. The memory numbers tell you about memory samples in those states, as minPss-avgPss-maxPss / minUss-avgUss-maxUss. The procstats tool also has a number of command line options to control its output — use adb shell dumpsys procstats -h to see a list of the available options.
Comparing this raw data from procstats with the visualization of its data we previously saw, we can see that it is showing only process run data from a subset of states: Imp Fg, Imp Bg, Service, Service Rs, and Receiver. These are the situations where the process is actively running in the background, for as long as it needs to complete the work it is doing. In terms of device memory use, these are the process states that tend to cause the most trouble: apps running in the background taking RAM from other things.
Quoted from: http://android-developers.blogspot.be/2014/01/process-stats-understanding-how-your.html Maybe you'll find more information using procstats -h or man procstats.
I am trying to monitor CPU usage using the top command in my android phone, using the following command:
Process p = Runtime.getRuntime().exec("top -m 15 -d 1 -n 1");
One of the output's of the top command I got is this:
User 2%, System 9%, IOW 0%, IRQ 0%
User 3 + Nice 0 + Sys 10 + Idle 95 + IOW 0 + IRQ 0 + SIRQ 0 = 108
PID PR CPU% S #THR VSS RSS PCY UID Name
743 0 15% R 1 2416K 948K bg u0_a692 top
15351 0 2% S 79 1921396K 114536K bg u0_a59 com.google.android.googlequicksearchbox:search
167 0 1% S 6 9668K 3512K logd /system/bin/logd
496 0 0% S 1 0K 0K root kworker/0:3
20447 0 0% S 1 0K 0K root kworker/u:34
I am using a Nexus 4 which has a quad core chip i.e. 4 CPUs
Here the total CPU usage is (intuitively) user + system = 11%. However, the top process itself takes 15% of the CPU. It happens most of the time. Here's a graph which I plotted using running the top command at an interval of 1s.
As seen in most cases, the top command uses more CPU than user and system CPU usage combined.
What causes this behavior?
I wanted to calculate how much CPU is used in an idle, sleep state. So, I thought of subtracting the CPU used by the top process from the combined CPU usage of user and system. But, having these kind of output cannot help me to determine exactly how much CPU the phone is using.
Also, is the CPU% of a process the total of user and system? i.e. if a process is utilizing 10% CPU, is it actually using something like 6% user and 4% system CPU?
It's a smart tvbox, 1.2GHz dual Cortex-A9 cpu, running Android 4.2.2. I'm using a USB Camera,when i'm run a camera demo, do nothing just preview, configure to 640x480, other params use default,and cpu usage is very high, if i use the default size 1280x720, the cpu usage is about 20%, strange, anyone knows? thks.
this is 640x480 adb shell top shows:
User 30%, System 44%, IOW 0%, IRQ 1%
User 178 + Nice 0 + Sys 259 + Idle 133 + IOW 0 + IRQ 0 + SIRQ 8 = 578
PID PR CPU% S #THR VSS RSS PCY UID Name
1762 1 19% S 20 133892K 24484K fg media /system/bin/mediaserver
1764 1 19% S 13 82036K 11712K fg system /system/bin/surfaceflinger
958 0 8% S 49 175308K 14360K root /vendor/bin/ampservice
I'm making application for watching movies which shows images of categories and movies in grid, list and horizontal scroll view.
App has several activities and in every one of them are shown images. Proglem is when user changes activities going only forward, in one point app crashes with OutOfMemory exception.
Using Heap and MAT tools i found that bitmap uses enormous memory of the heap in every activity. On same phones, like Samsung Galaxy S4 and Alcatel OneTouch Idol with full HD display, app crashes in just 2-3 activities. That is crazy :)
So, my question is, how can i overcome this problem with memory?
I know that this is ordinary Android problem but there must be something that I can do to fix this.
Every image is optimazed for its place ( image dimensions are precisely measured before attached to image view).
Cheers.
Do some profiling .
You didn't provide any code or logs .So ,will tell you basic approach which i follow .
start your first activity . Continously run adb shell dumpsys "PID" or "PackageName" .
Get info while you reproduce activity .
execute adb shell " while true ; do dumpsys meminfo 22188 ; done ; " > dumpsysOfsmthn.txt
* MEMINFO in pid 22188 [com.sec.android.smthn] **
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 44 44 0 0 11132 10455 184
Dalvik Heap 19189 18804 0 0 25660 19221 6439
Dalvik Other 3891 3828 0 0
Stack 200 200 0 0
Ashmem 2 0 0 0
Other dev 8168 7844 4 0
.so mmap 1990 1032 508 0
.jar mmap 5 0 4 0
.apk mmap 315 0 124 0
.ttf mmap 21 0 4 0
.dex mmap 6553 248 5584 0
Other mmap 90 4 20 0
Unknown 5743 5740 0 0
TOTAL 46211 37744 6248 0 36792 29676 6623
Objects
Views: 39 ViewRootImpl: 1
AppContexts: 4 Activities: 1
Assets: 3 AssetManagers: 3
Local Binders: 78 Proxy Binders: 42
Death Recipients: 2
OpenSSL Sockets: 0
SQL
MEMORY_USED: 286
PAGECACHE_OVERFLOW: 53 MALLOC_SIZE: 62
DATABASES
pgsz dbsz Lookaside(b) cache Dbname
4 24 53 2/17/3 /data/data/com.sec.android.smthn/databases/sns.db
4 32 55 1/13/2 /data/data/com.sec.android.smthn/databases/picasa.db
4 36 27 10/17/3 /data/data/com.sec.android.smthn/databases/local.db
Applications Memory Usage (kB):
Uptime: 31556347 Realtime: 96096816
Check which part of portion is increasing constantly .
It could be ViewRootImpl or activity context or anything .
Above information might get you to some clue .
As told take heapdump analyse it with MAT or JHAT .
Mat is awewome tool IMHO .
you should look for memory leaks caused by:
Long-lived references to an Activity, Context, View, Drawable, and other objects that may hold a reference to the container Activity or Context.
Non-static inner classes (such as a Runnable, which can hold the Activity instance).
Caches that hold objects longer than necessary.
Leak can be caused by any Object.Generally bitmaps are big. And if the out-of memory occurs very easily then you need to check on heavy objects like bitmaps.
For MAT and Leaks understanding Click this
Also this .
Also apart from above things you can also use DDMS allocation tracker to get more clue > yeah nothing can get better data than MAT .
Also check this post . Very informative