first question is in my mind is how to know application heap size available to an Android app. ofcourse it may vary on the basis of phone device.
PSS : Proportional Set Size
Amount of memory shared with other processes, account 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 “contribution” to overall memory load.
USS : Unique Set Size
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 gets terminated.
Runtime memory available for allocation (Used by applications, services, daemons)
The dalvik heap is preloaded with classes and data by zygote.
Commands for run time memory usage
- To spit out a bunch of information about the memory use of each JAVA process
$adb shell dumpsys meminfo
- To see memory for particular process: ( e.g. System)
$adb shell dumpsys meminfo system
- Summary of the overall memory
$adb shell cat /proc/meminfo
Run Time Memory: Gallery Use Case
Rum time memory usage will depends on kind of use case running on android system. Following are the context where – run time memory will be allocated by android system.
- All java process will run with the instance of DVM. DVM will again have its own run time heap requirement based on java application code complexity.
- Binder IPC will allocate run time memory for marshalling objects
- Service or daemon will allocated run time memory for internal usage
- Following example will show run time heap change with respect to gallery application use case.
- Size : Total size of particular heap
- Allocated : Portion of heap is allocated to process
- Native Usage : Usage by application or service code
- Dalvik Usage : Usage by Dalvik virtual machine (libdvm)
Android's inbult API ActivityManager.getProcessMemoryInfo return few more interesting numbers.