How to increase heap size of an android application?

后端 未结 7 1563
天涯浪人
天涯浪人 2020-11-22 06:41

I am writing an Android application which uses several 3D models. Such a model with textures can take up a lot of memory. I found out the manufacturer sets a limit on the he

相关标签:
7条回答
  • 2020-11-22 07:27

    Is there a way to increase this size of memory an application can use?

    Applications running on API Level 11+ can have android:largeHeap="true" on the <application> element in the manifest to request a larger-than-normal heap size, and getLargeMemoryClass() on ActivityManager will tell you how big that heap is. However:

    1. This only works on API Level 11+ (i.e., Honeycomb and beyond)

    2. There is no guarantee how large the large heap will be

    3. The user will perceive your large-heap request, because it will force their other apps out of RAM terminate other apps' processes to free up system RAM for use by your large heap

    4. Because of #3, and the fact that I expect that android:largeHeap will be abused, support for this may be abandoned in the future, or the user may be warned about this at install time (e.g., you will need to request a special permission for it)

    5. Presently, this feature is lightly documented

    0 讨论(0)
提交回复
热议问题