NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
Android gingerbread memory analysis for non-phone device
Content is no longer maintained and is being kept for reference only!
Contents
Introduction[edit]
Android migration to non-mobile segments raises the need of memory footprint analysis to lower down the cost of product; specifically run-time memory utilization. There are many applications such as phone,contacts etc. does not play role to these segments. They would give good deal at run-time by giving run-time space to other applications.
Document will put lights on run-time memory analysis and different android configurations which enable android to run with lower run-time memory.
With respect to reference mentioned at http://processors.wiki.ti.com/index.php/Android_Memory_Analysis; minimal run memory requirement to run basic android features (standard android source form Google Inc.) is 256MB. However considering specific use cases for non-phone segment, this number (256MB) can be lower down to gain on cost.
Note: : Memory figures described in this documents are based on experiment with TI's AM37xevm & TI's devkit release 2.3.1
http://software-dl.ti.com/dsps/dsps_public_sw/sdo_tii/TI_Android_DevKit/TI_Android_GingerBread_2_3_DevKit_1_0/index_FDS.html
Android Runtime Memory Analysis[edit]
Android Framework : Memory FootPrint
[edit]
- Below table brief about minimum memory requirments for the different core components of android os. Average 65-80 MB of minimum memory required for android to boot with sgx support. After boot android will launch many services and applications, which will add more memory to listed figure. ( Application & Services will start creating instances of dalvik VM & many other objects)
module# | Description# | Approx size in MB | Remark# |
---|---|---|---|
Core Java Libraries | A set of Java libraries used by various components of the Android system | 13 | Libraries will allocate more space run time to create instances per application bases |
Core System Libraries | A set of C/C++ libraries used by various components of the Android system. Includes system c libraries, webcore ( for browser), sgx, bluetooth,SQLlite,freetype and other misc. | 27 | |
Surface Flinger | Manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications | 5 |
Surface flinger will allocate buffers for - Display surface - Launcher - Status bar – normal & expanded This can vary depending on resolution of display system. Figure shown over here is for 640x480 resolution |
Dalvik | Vritual machine to run android java applications. | 1.5 - 16 | Every Android application runs in its own process, with its own instance of the Dalvik virtual machine.16MB is max heap size that dalvik VM will used. This can be configurable. |
SGX | This module speed up graphics experience by using h/w accelarated graphics | 8 - 40 | min 8 MB + use case requirement; This number can go upto 40 MB. Ex. Gallery icon grid view : 4 x 4, each icon is of 100x100 pixel then sgx will allocate : 100x100x2( bytes per pixel) x 4 x4 = 312 KB + background ( 640x480x2) |
Cached Memory | Buffer cache. | 14-20 |
[edit]
Android At Runtime[edit]
- Below table briefs about run-time memory utilization by different android processes & applications
Note: Represent data are taken from RSS (Resident Set Size) field of "ps -a" command. However data collected from various memory tools like DDMS,smem, /proc/meminfo,dumsys are giving similar data what is presented over here. Reason to choose RSS is -one can measure physical pages occupied by process at a moment, which give RAM utilization by running processes. For more details on RSS refer
# | process# | size in MB#RSS | remark# |
---|---|---|---|
Android core processes (required for normal boot) |
zygote | 16 | |
system_server | 34 | running 41 diff services, ref # frameworks/base/services/java/com/android/server/SystemServer.java | |
com.android.systemui | 19 | Handles all notification on status bar. This can be removed from android file system if there is no need of any notification handling for the product use case. | |
mediaserver | 1.5 | ||
Other Processes ( which can be killed in low memory scenario) |
com.android.launcher | 21 | |
com.android.phone | 15 | ||
com.android.bluetooth | 16 | ||
Gallery/Music |
android.process.media | 18 | |
com.cooliris.media | 17 | ||
com.android.inputmethod.latin | 5 |
- With respect to memory figures mentioned in table, minimun android boot configuration : android core process (16 +34+19+1.5) + com.android.launcher (21) - will require around 91.5 MB of memory. Presented figures are with respect to default gingerbread devkit release for AM37xevm.
Android Customized Configuration[edit]
This section presents various android customized configurations, which can be run on non-phone devices with memory less than 256MB.
Note: Only sanity test cycle has been validated against following described configurations.
Customizing Android Product Package[edit]
- Step 1: Customize android product package from file#<android-source>/build/target/product/generic.mk.
- Actual file reference#http://gitorious.org/rowboat/build/blobs/rowboat-gingerbread/target/product/generic.mk
>> open file: <android-source>/build/target/product/generic.mk >> Remove all packages which are not required for product use case >> Following configuration has been choosen for experiment Note : Choosing Galley(2D)over Gallery3D will save extra space required for thumbnail caching & 3D accelration by SGX PRODUCT_PACKAGES := \ Bluetooth \ CertInstaller \ DrmProvider \ Gallery \ Launcher2 \ Music \ Provision \ Settings \ SystemUI \ LatinIME \
- Step 2: Remove phone support
- Actual file reference#http://gitorious.org/rowboat/build/blobs/master/target/product/core.mk
>> open file: <android-source>/build/target/product/core.mk >> remove following packages ( listed with '-' sign) PRODUCT_PACKAGES := \ libz \ sqlite-jdbc \ Browser \ - Contacts \ Home \ HTMLViewer \ - Phone \ ApplicationsProvider \ - ContactsProvider \ DownloadProvider \ DownloadProviderUi \ MediaProvider \ PicoTts \ SettingsProvider \ - TelephonyProvider \ TtsService \ VpnServices \ - UserDictionaryProvider \ PackageInstaller \ DefaultContainerService \ Bugreport
Note : One can also remove Browser if it is not a part of product use case.
- Step 2.1: Remove Services(Optional): Location Manager,Vibrator,Telephony Registry
- Removing above mentioned services will remove support for telephony, location and vibrator.Run-time memory gain will be ~3MB + Performance.
- Patch Reference#http://processors.wiki.ti.com/index.php/File:0001-removed-telephony-vibratior-location-manager-service.patch
Kindly apply patch to <android-src>/frameworks/base $patch -p1 < {patch-file}
- Step 2.2: Remove Wallpaper Service( Optional)
- Removing wallpaper service will create black background. No wallpaper can be set as background.Run-time memory gain will be ~2MB+ performance(specifically switching between views).
- Patch Reference#http://processors.wiki.ti.com/index.php/File:0001-wallpaper-service-dependency-removed.patch
## Remove following lines from file :<android-src>/frameworks/base/services/java/com/android/server/SystemServer.java - try { - Slog.i(TAG, "Wallpaper Service"); - wallpaper = new WallpaperManagerService(context); - ServiceManager.addService(Context.WALLPAPER_SERVICE, wallpaper); - } catch (Throwable e) { - Slog.e(TAG, "Failure starting Wallpaper Service", e); - } ## Remove wallpaper dependency from launcher application Kindly apply mentioned patch to <android-src>/packages/apps/Launcher2 $patch -p1 < {patch-file}
- Step 3: Build customized product configuration.Follow the step given at #http://processors.wiki.ti.com/index.php/TI-Android-GingerBread-2.3-DevKit-1.0_UserGuide#Building_Android_Sources
- Step 4: Flash newly build file system and boot the target
Configuration1 : 144 MB run-time memory[edit]
- Customized package created with steps mentioned at section:"Customizing Android Product Package excluding step 2.1 & 2.2"
- Display Configuration is : 640x480-16 bpp(bits per pixel)
- Boot arguments
setenv bootargs 'console=ttyO0,115200n8 androidboot.console=ttyO0 mem=144M root=/dev/mmcblk0p2 rw rootfstype=ext3 rootdelay=1 init=/init ip=dhcp omap_vout.vid1_static_vrfb_alloc=y vram="2M" omapfb.vram=0:2M‘
- Observations:
- Normal boot
- Gallery, Music, Bluetooth, Wifi, Browser, Settings - operations are normal as expected
Configuration2 : 128 MB run-time memory[edit]
- Customized package created with steps mentioned at section:"Customizing Android Product Package excluding step 2.1 & 2.2"
- Display Configuration is : 640x480-16 bpp(bits per pixel)
- Boot arguments
setenv bootargs 'console=ttyO0,115200n8 androidboot.console=ttyO0 mem=128M root=/dev/mmcblk0p2 rw rootfstype=ext3 rootdelay=1 init=/init ip=dhcp omap_vout.vid1_static_vrfb_alloc=y vram="2M" omapfb.vram=0:2M‘
- Observations:
- Normal boot
- Gallery, Music, Wifi, Browser, Settings - operations are normal as expected
- Bluetooth connectivity is fine
- However sometime file transfer over bluetooth suffers from "low memory" and service gets killed.
Configuration3 : 128 MB run-time memory[edit]
- Customized package created by removing SystemUI( no statusbar) & LatinIME (no virtual keyboard support)
- Display Configuration is : 640x480-16 bpp(bits per pixel)
- Boot arguments
setenv bootargs 'console=ttyO0,115200n8 androidboot.console=ttyO0 mem=128M root=/dev/mmcblk0p2 rw rootfstype=ext3 rootdelay=1 init=/init ip=dhcp omap_vout.vid1_static_vrfb_alloc=y vram="2M" omapfb.vram=0:2M‘
- Observations:
- Normal boot
- Gallery, Music, Wifi, Browser, Settings - operations are normal as expected
- No virtual keyboard, one has to have external keyboard to enter text.
- Sending a file over bluetooth works fine.
- Receiving a file over bluetooth can not be tested as notification comes over status bar; which is not a part of this package
Configuration4 : 128 MB run-time memory, No SGX[edit]
- Customized package created with steps mentioned at section:"Customizing Android Product Package"
- To build android source without sgx; Kindly refer link# http://processors.wiki.ti.com/index.php/Building_TI_Android_DevKit_Filesystem_without_SGX
- Display Configuration is : 640x480-16 bpp(bits per pixel)
- Boot arguments
setenv bootargs 'console=ttyO0,115200n8 androidboot.console=ttyO0 mem=128M root=/dev/mmcblk0p2 rw rootfstype=ext3 rootdelay=1 init=/init ip=dhcp omap_vout.vid1_static_vrfb_alloc=y‘
- Observations:
- Normal boot
- Gallery, Music, Wifi, Browser,Bluetooth, Settings - operations are normal as expected
- Graphics experience is poor compared to SGX powered graphics.
- If step 2.1 & 2.2 gets included in customized build, then system can run with 114MB memory without sgx
Summary Note[edit]
- It is recommended to have minimum of 256MB of run-time memory to have SGX powered android with all basic features.
- However to win on product cost, one can always customized & optimize android if it is used for specific use cases. Some of customization is already discussed in this guide.
- Running QVGA resolution(320x240) with 128MB of run-time memory should give better android experience.As all graphics,icons,textures,wallpaper etc will take less run-time memory.
- For the customers who want to deploy their own applications or services which takes more run time memory; kindly consider following point. This can help to choose suitable run-time memory.
- Considering 'A1' as Customer’s application which requires more than 100MB (and less then 150 MB) of run-time memory.If A1 & other android applications of android is not running simultaneously ( specifically bluetooth/gallery/luncher) then 256 MB of run time memory is enough for android execution with A1
Disclaimer[edit]
- All memory figures listed in this wiki are based on experiments with TI's am37xevm & TI's gingerbread devkit release.These may differ for other targets & android releases.
- Experiments are validated with sanity test only. It may give unexpected results with some use cases.
- RSS( Resident Set Size) field gives value in KB(Kilo Bytes),same has been rounded up in MB(Mega Bytes)
References[edit]
http://processors.wiki.ti.com/index.php/Android_Memory_Analysis
http://software-dl.ti.com/dsps/dsps_public_sw/sdo_tii/TI_Android_DevKit/TI_Android_GingerBread_2_3_DevKit_1_0/index_FDS.html
http://stackoverflow.com/questions/2298208/how-to-discover-memory-usage-of-my-application-in-android/2299813#2299813
http://www.koushikdutta.com/2009/01/dalvik-vs-mono.html
Support[edit]
- Follow us on twitter : http://twitter.com/arowboattwits for instant notifications
- Our community page : http://arowboat.org
- Our blog : http://arowboat.wordpress.com
- For support and queries please use http://e2e.ti.com/android