How to increase heap size of an android application?

后端 未结 7 1730
天涯浪人
天涯浪人 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:15

    you can't increase the heap size dynamically.

    you can request to use more by using android:largeHeap="true" in the manifest.

    also, you can use native memory (NDK & JNI) , so you actually bypass the heap size limitation.

    here are some posts i've made about it:

    • How to cache bitmaps into native memory

    • JNI bitmap operations , for helping to avoid OOM when using large images

    and here's a library i've made for it:

    • https://github.com/AndroidDeveloperLB/AndroidJniBitmapOperations

提交回复
热议问题