Android app reason of large RAM usage and how to reduce

眉间皱痕 提交于 2019-12-11 04:38:41

问题


When I launch and exit my app several times its RAM usage increases reaching over 500 mb. When I checked memory dump using adb shell dumpsys meminfo I checked unknown pss value is cause of problem. What is reason of large pss value and how I can reduce pss value.

Shared  Private     Heap     Heap     Heap

                   Pss    Dirty    Dirty     Size    Alloc     Free

                ------   ------   ------   ------   ------   ------

       Native        0        0        0   534460   531827     1604
       Dalvik    51013    17868    50664    90480    82266     8214
       Cursor        0        0        0                           
       Ashmem        0        0        0                           
    Other dev    14292       52    14288                           
     .so mmap     3810     2320     1720                           
    .jar mmap        0        0        0                           
    .apk mmap     1305        0        0                           
    .ttf mmap        0        0        0                           
    .dex mmap     2960        0        0                           
   Other mmap     1738      440      236                           
      Unknown   504718      296   384284                           
        TOTAL   579836    20976   451192   624940   614093     9818

回答1:


I found out reason of high RAM usage. When I analyzed native heap dump of app I got to know that instances of library libharfbuzz.so was taking up huge space and that library is used for displaying fonts, so when I checked code there were lot of instances of TypeFace cretaed in code at number of places. As TypeFace are allocated in native memory and it makes native heap size large thats why RAM usage was more. I removed those instances and created single TypeFace instance and used it in my app and RAM usage was decreased.



来源:https://stackoverflow.com/questions/19562252/android-app-reason-of-large-ram-usage-and-how-to-reduce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!