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



留言

搜尋

本月熱門文章

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

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

什麼是Sanity test ? 軟體測試常見名詞整理

水電行介紹---台北市北投區致遠二路113巷7號的揚明水電行‎—在地老店,水電服務的好鄰居

水電行介紹---台北市松山區延吉街的廣泰水電行—在地經營水電行,來電預約跨區跑也OK啦~

廚具水電行—呼叫臺北市內湖區民權東路6段56巷1弄2號的永輝水電衛浴廚具行 –有廚浴, 衛浴展示空間喔!

水電行介紹---台北市大同區重慶北路二段101號的永發水電行---公車直達的水電行!

水電行介紹---台北市萬華區東園街47號的正泰水電裝潢行---水電廚具衛浴找我就對啦!

水電行介紹---臺北市大同區歸綏路197號1樓的新雅水電行---32歲的在地水電行。

水電材料行介紹---臺北市大同區寧夏路75號的順利電料有限公司 ---在地經營二十四年的水電材料行,請大家繼續支持!

Agoda

熱門文章

[社會觀察] 一生順遂與命途乖舛

中華民國2024 總統、副總統選舉公告發布 連署參選門檻28萬9667人 可以推薦候選人的政黨包括民進黨、國民黨、民眾黨和時力

關於中國:202X年

[FAANG面試] 如何準備Google Technical Program Manager (TPM) 面試

[HMD Global] Nokia 2020 新手機發布 首款 5G 手機 Nokia 8.3 預計夏季開賣 !

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

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

[音樂] 霖霖 新單曲:給你了

[表特][Passion Sisters] 中信兄弟PS女孩 浮誇甜心 凱蒂 炸裂全場~ 小許瑋甯