Android gingerbread memory analysis for non-phone device

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

Construction Icon small.png This page is currently under construction. The content of this page is due to change quite frequently and thus the quality and accuracy are not guaranteed until this message has been removed. Please feel free to contribute to this page while construction is in progress.



Contents

Introduction

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.

NoteNote:  : 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

Android Framework : Memory FootPrint


Table 1 : android memory - framework
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

Android At Runtime

NoteNote:  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


Table 2: Android at run-time
# 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


Android Customized Configuration

This section presents various android customized configurations, which can be run on non-phone devices with memory less than 256MB.

NoteNote:  Only sanity test cycle has been validated against following described configurations.  

Customizing Android Product Package

>> 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 \

>> 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.
Kindly apply patch to <android-src>/frameworks/base
$patch -p1 < {patch-file}
## 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}

Configuration1 : 144 MB run-time memory

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‘

Configuration2 : 128 MB run-time memory

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‘

Configuration3 : 128 MB run-time memory

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‘

Configuration4 : 128 MB run-time memory, No SGX

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‘

Summary Note

Disclaimer

References

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

E2e.jpg For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Android gingerbread memory analysis for non-phone device here.
Hyperlink blue.png Links
ARM Microcontroller MCU ARM Processor Digital Media Processor Digital Signal Processing Microcontroller MCU Multi Core Processor
Ultra Low Power DSP 8 bit Microcontroller MCU 16 bit Microcontroller MCU 32 bit Microcontroller MCU

Leave a Comment
Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox