简体   繁体   中英

Heap size issue in android app

I am having an app which starts a started service, Uses Manager classes(Which loads all the necessary data from SQLITE into these singleton classes). And DDMS is showing Heap size for my app to be 7.00 MB while my app consuming is 5.80 MB of heap size. Just 1.20 MB approx is left. And this is when my app is not having much data. How to fight againts such a problem???Please help!

If you dont have any idea of how the heap is been used in you app. use memory Analyzer in DDMS to find it. Its a plugin which can be integrated to eclipse. It will show you which process takes more heap and you can track it down and rectify.

  1. If unused bitmaps are not cleared, the garbage collector will not clear those memory and it will take a lot of heap in runtime.

  2. Heap really get burned when you dont clear unused objects of mediaplayer, recorder, bitmap and vedio processor.

I dont know what is the exact functionality of your app. Please check any of this components, if you have used in your app. I guess this may be the reason for heap memory conception. Try to clear all the unused objects by making it to null.

There are two solutions: either try to reduce your memory usage, trim some data loaded to your manager classes and load them when necessary, or if you are sure your app will be using more memory than a normal android process, you can use largeHeap tag to specify this.

That being said, the number you see in DDMS is not the final amount of RAM OS assigns to your process. That's the initial heap, and after some time if needed OS assigns more heap to your process. But there is a cap, which is different on different phones.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM