开发者

Alternative of VMRuntime.getRuntime().setMinimumHeapSize in Gingerbread

I 开发者_开发技巧know there's a VMRuntime.getRuntime().setMinimumHeapSize in Android 2.1/2.2 for developer to adjust the starting heap size of the application, and it is one of the most effective solution sfor solving the OutOfMemory error during BitmapFactory.decodeStream()

However, since Android 2.3, this VMRuntime class is removed from official API, does anyone knows the alternative API of this function in 2.3?


and it is one of the most effective solution sfor solving the OutOfMemory error during BitmapFactory.decodeStream()

Really? Setting the minimum heap size may reduce GC churn, but I would love to see links to places where it helped with OutOfMemoryErrors.

However, since Android 2.3, this VMRuntime class is removed from official API, does anyone knows the alternative API of this function in 2.3?

There is none. That behavior is no longer exposed.


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, 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


Similar answer to increase the heap size of the application

You cannot use VMRuntime post 2.2 but this functionality shall solve your purpose

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜