this post is really a question, doesn't contain the answer Orz

this big question may consist of several items

what is memory leak ? 

how  to monitor Android system memory and performance ?

linux command :

ps -x
cat /proc/meminfo

not know exactly : 

dumpsys meminfo proc-id
time command-line

and DDMS (Android SDK tool) !!

Could automatic track memory leak on Android ?

DDMS could help !

but need to do some settings ( group discuss Finding Memory leak in native code )

0. Build 

1. replace system/lib/ with /system/lib/ 

2. set environment variables 

 $PATH with ~/open_src/prebuilt/linux-x86/toolchain/arm-eabi-XXX/bin
 $ANDROID_PRODUCT_OUT with ~/open_src/out/target/product/

'PATH' is used for getting "arm-eabi-addr2line" and
ANDROID_PRODUCT_OUT for getting the path to /symbol folder. 

3. restart the framework.  

adb shell stop && adb shell start 

4. Add "native=true" to  ~/.android/ddms.cfg

5. start the stand-alone version of DDMS.  -> "Native Heap" 

but just know that there  was an malloc @@ !!

how to avoid memory leak in application ?

from Avoid memory leaks on Android suggestion:

  • Do not keep long-lived references to a context-activity (a reference to an activity should have the same life cycle as the activity itself)
  • Try using the context-application instead of a context-activity
  • Avoid non-static inner classes in an activity if you don’t control their life cycle, use a static inner class and make a weak reference to the activity inside

to be continued ...


    tttt 發表在 痞客邦 留言(0) 人氣()