How to increase heap size of an android application?

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

    This can be done by two ways according to your Android OS.

    1. You can use android:largeHeap="true" in application tag of Android manifest to request a larger heap size, but this will not work on any pre Honeycomb devices.
    2. On pre 2.3 devices, you can use the VMRuntime class, but this will not work on Gingerbread and above See below how to do it.
    VMRuntime.getRuntime().setMinimumHeapSize(BIGGER_SIZE);
    

    Before Setting HeapSize make sure that you have entered the appropriate size which will not affect other application or OS functionality. Before settings just check how much size your app takes & then set the size just to fulfill your job. Dont use so much of memory otherwise other apps might affect.

    Reference: http://dwij.co.in/increase-heap-size-of-android-application

提交回复
热议问题