Monday, January 16, 2012

How to know My Android Application/Process killed due to low Memory?


Prerequisites :
   1) ICS(Ice cream sandwich) AOSP code - 4.0.3

These are the pointers to verify in native source code for the "low-memory" condition.

1) Detect "Out of Memory on" situation in the below functions

    Function Names : dvmMalloc() calls
                                 tryMalloc ()
    File Name          : Heap.cpp
    Path                   : /dalvik/vm/alloc

2) ActivityManager kill the process.

    Function Name   : requestFinishActivityLocked
    File Name           : ActivityStack.java
    Path                    : /frameworks/base/services/java/com/android/server/am

3) Report process is died.

    Function Name   : appDiedLocked
    File Name           : ActivityManagerService.java
    Path                    : frameworks/base/services/java/com/android/server/am/

Enable the Native logs in above functions, and from this you can confirm that the application is getting killed because of low memory.

Check this link to know "How to enable native logs".

Note :  execute '/proc/meminfo' to know the current status of memory consumed, memory free etc..

No comments:

Post a Comment