Android Memory Usage
The memory of an Android system is managed by several different allocators, in several different pools.
You can examine the system's view of the memory on the machine, by examining /proc/meminfo.
If you use 'ddms', you can see a summary of the memory used on the machine, by the system and by the different executing processes. Click on the SysInfo tab, and select "Memory Usage" in the box on the upper left of the pane.
Here's a screenshot:
Note that you can get the numbers for each process by hovering your mouse over a particular pie slice. Numbers are shown in K and percentages.
You can see an individual process' memory usage by examining /proc/<pid>/status
Details about memory usage are in
The 'top' command will show VSS and RSS.
Also, see ddms info above.
You can see very detailed per-process or systemwide memory information with smem.
The Dalvik heap is preloaded with classes and data by zygote (loading over 1900 classes as of Android version 2.2). When zygote forks to start an android application, the new application gets a copy-on-write mapping of this heap. As Dan Borstein says below, this helps with memory reduction as well as application startup time.
Dalvik, like virtual machines for many other languages, does garbage collection on the heap. There appears to be a separate thread (called the HeapWorker) in each VM process that performs the garbage collection actions. (See toolbox ps -t) [need more notes on the garbage collection]
Dan Borstein said this about heap sharing:[INFO NEEDED: how to show dalvik heap info?]
- [comment Jan 2009 to Blog article Dalvik vs. Mono