Memory and CPU per process ANDROID

独自空忆成欢 提交于 2019-12-04 21:44:44
  1. CPU load - you need to read the /proc/[pid]/stat (ref http://linux.die.net/man/5/proc). Looking for utime & stime, they are the times the process spends on user mode and kernel mode. A good example to see how it works, you can find the source code of the top utility (check out the read_stat function in top.c).

  2. Memory usage - traditionally, people read /proc/[pid]/stat again for the rss field. Now it is more popular to use the PSS. (ref http://developer.android.com/reference/android/os/Debug.html#getPss%28%29). You can wiki the definition and difference of RSS and PSS - it is something to do with the size of global share library.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!