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



留言

搜尋

本月熱門文章

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

水電行介紹---台北市萬華區環河南路一段216號的光成水電材料行---我在修繕業的叢聚市場

什麼是 OTA ?

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

水電行介紹---台北市南港區研究院路二段30號的志興水電行---是水電行也是水電材料行

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

水電行介紹---臺北市信義區大道路36號的廣福水電行-----在地14年的水電行,廚具、水電、水電材料找我就對了~

網紅控遭NONO「載到暗處伸手摸」!怒受害者不只1人「被拖到廁所侵害」

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

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

Agoda

熱門文章

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

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

關於中國:202X年

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

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

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

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

[棒球] 2023 台灣大賽G5 威能帝13K飆破紀錄 猿3轟搶聽牌優勢