Tuesday, July 5, 2011

Android command line tools for memory analysis

We can use two command line tools to analyze memory usage by any android app.

1. Procrank

a. This command will show quick summary of memory utilization for all running processes on emulator/device. It shows six columns in output.
  • PID- Process ID
  • Vss - Virtual set size
  • Rss - Resident set size
  • Pss - Proportional set size
  • Uss - Unique set size
  • Cmdline - Process name

b. Only two columns (Pss and Uss) need to be watched closely. Vss and Rss and worthless because they don't accurately reflect a process's usage of pages shared with other processes.

c. Uss is the set of pages that are unique to a process. This is the amount of memory that would be freed if the application was terminated right now.

d. Pss is the amount of memory shared with other processes, accounted in a way that the amount is divided evenly between the processes that share it. This is memory that would not be released if the process was terminated, but is indicative of the amount that this process is "contributing" to the overall memory load.

e. Use below mentioned command to execute this procrank tool and get memory usage details

C:/../ADB_PATH>adb shell procrank



2. Dumpsys/meminfo
a. This gives more detailed memory analysis than procrank.

b. It gives details like how many views, activities are in memory at any point

c. It also gives info about database used by that app

d. Use below mentioned command to execute this tool and get memory usage details for specific app (in this case com.est.myapp)

C:/../ADB_PATH>adb shell dumpsys meminfo com.est.myapp



Note: These commands may not work on all devices.

1 comment:

  1. Great post!!Thanks for sharing it with us....really needed.Our mission is to understand the value proposition of your business to better target your potential customers, in order to maximize the possibility of converting them into a qualified prospects.google ads

    ReplyDelete