Android app consuming a lot of native heap space
Asked Answered
W

0

3

I am trying to reduce the memory usage of my app.I started by fixing memory leaks in my code.This reduced the Dalvik heap space considerably but no difference in the native heap space allocated.

Is there a way I can reduce my native heap space consumption. If so, how should I go about doing it?

Heres what my app's heap dump looks like ""

                   Pss  Private  Private  Swapped     Heap     Heap     Heap
                 Total    Dirty    Clean    Dirty     Size    Alloc     Free
                ------   ------   ------   ------   ------   ------   ------
  Native Heap    27240    27208        0        0    57344    24872    32471
  Dalvik Heap    27138    26804        0        0    49430    41737     7693
 Dalvik Other      624      624        0        0                           
        Stack      924      924        0        0                           
      Gfx dev     8738     5788        0        0                           
    Other dev       16        0       16        0                           
     .so mmap      833      332      124        0                           
    .apk mmap      634        0      176        0                           
    .ttf mmap       32        0        0        0                           
    .dex mmap    12484        0    12480        0                           
    .oat mmap     1146        0      124        0                           
    .art mmap     1395     1212        4        0                           
   Other mmap       44        4        0        0                           
      Unknown      160      160        0        0                           
        TOTAL    81408    63056    12924        0   106774    66609    40164

 Objects
               Views:      919         ViewRootImpl:        1
         AppContexts:        3           Activities:        1
              Assets:      214        AssetManagers:      214
       Local Binders:       85        Proxy Binders:       22
       Parcel memory:       24         Parcel count:       96
    Death Recipients:        0      OpenSSL Sockets:        3

 SQL
         MEMORY_USED:        0
  PAGECACHE_OVERFLOW:        0          MALLOC_SIZE:        0
Widower answered 10/12, 2015 at 13:10 Comment(6)
I actually don't see high memory use at all? The native heap is pretty much 50% unused, so I can't see the problem.Eugeniusz
But in the clean master app, the memory usage shows the figure for the row "TOTAL" under the "Pss Total" column which is "81408". And ~27MB each is used for Native and Dalvik heaps under the "Pss Total" column. I am trying to get a sense of what affects the "Native Heap".For other similar apps it stands at ~12MB.Widower
What other apps? Are they doing the same thing? Load the same images? Load the same data? It's difficult to measure memory usage against other apps that do different things. Look and how big the .dex mmap is, that means you have a lot of code loaded into memory, for example, which is bound to be different for each application. The biggest culprits for memory is usually images - are you using lots of graphics by any chance?Eugeniusz
Yes, I am using a lot of images. I understand that I shouldnt compare it with other apps. The reason I was doing that is because i dont know how much that figure should typically be and was wondering if there was a problem in my code that was causing the native heap space to be high.Widower
The native heap space is used for images so the more images you have, the bigger it will grow. Make sure you only use the images you need and that you get rid of images you loaded as soon as you can to prevent running out of memory. That being said, your application is not using that much memory at all. Depending on the type of device, a bitmap that fills, let's say, half the screen, will take up a sizeable chunk of memory. Also, even though the heap is of a certain size, you are not using the entire heap, so it looks to me like your app is not in danger of running out of memory soon.Eugeniusz
Thank you.This information helps :)Widower

© 2022 - 2024 — McMap. All rights reserved.