how to trace memory leak in Android ?

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
top
cat /proc/meminfo


not know exactly : 


dumpsys meminfo proc-id
procrank
time command-line
vmstat


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 libc_debug.so 


1. replace system/lib/libc.so with /system/lib/libc_debug.so 


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



留言

Google Search

推薦內容橫式

本月熱門文章

[FAANG面試] Amazon/AWS 領導力準則 14 Amazon Leadership Principles

柯文哲弊案:關於橘子

民眾黨柯文哲貼身帳房“橘子”滯留日本尚未回台

日本旅行 去東京可以在哪邊買羽球相關用品? WEMBLEY/WINDSOR/梭家/Victoria/Alpen TOKYO

颱風天注意安全 北北基桃明天停課

[雲端服務] Google 帳戶儲存空間管理:釋放更多空間的有效方法

許多深藍人士懷念的兩蔣時代

蔣經國時代 1979年 美麗島事件 回顧

PM到底在做什麼 ? Project Manager, Product Manager 以及 Program Manager的差別

中文的奧妙 柯文哲及吳慷仁金句為例

這個網誌中的熱門文章

Android應用開發豆知識:利用 adb 安裝 apk 到裝置上

Android 中文輸入法 官方版 ! Gboard - Google 鍵盤 開始支援注音輸入啦

Google Play 推薦Android app 誠徵App排行榜

北京故宮首訪,一窺清宮秘史 大玉兒 & 甄嬛

[家教][社會觀察] 建中教我的事 沒上建中被父母親折磨? 在建中到底是如何 ...

[FAANG面試] Amazon/AWS 領導力準則 14 Amazon Leadership Principles

Acer ICONIA Smart S300 更新後越來越好 Acer也有出手機?!

[品質控制] 什麼是Sanity test ? 軟體測試常見名詞整理 包含不同部門的測試人員負責範圍

新鮮人找工作:職場名詞解釋 AE FAE Pre-sales Post-sales