问题描述
我得到一个OutOfMemoryError,当我尝试创建一个字符串
使用4MB相比较大 StringBuilder.append()
据我所知,的StringBuilder
没有任何限制有关尺寸等不字符串
所以,我搜索如何增加Android的堆大小而据我可以从this回答和this回答,姜饼是在你没有对付堆大小的方式,因为早期版本使用VMRuntime类和较新版本的Android的唯一版本:largeHeap =真
的清单。
是假设是正确的?当你在VMRuntime之间是你做什么和的android:largeHeap =真正的
我用调用Runtime.getRuntime()totalMemory()/ 1048576 - 调用Runtime.getRuntime()maxMemory()/ 1048576
来得到5.00 MB分配42.00 MB。可用我使用的测试(Android版2.3.6)在设备上。
I cannot say whether VMRuntime
ever worked. android:largeHeap
is definitely something for API Level 11+.
Find a more memory-efficient way of building your 4MB String
, such as by providing a large capacity to your StringBuilder
constructor.
Or, find a way to implement whatever it is that you are doing without creating a contiguous 4MB String
.
这篇关于如何增加的Android 2.3(姜饼)堆大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!