[英]How to allocate more than 25MB in an android app, api level 8?
I'm trying to write a quick android app to exert memory pressure on another app that I am debugging, and I am running into a big problem, namely that I cannot allocate more than 25MB, even if I allocate in as small as 4k chunks. 我正在尝试编写一个快速的Android应用程序来对我正在调试的另一个应用程序施加内存压力,我遇到了一个大问题,即我不能分配超过25MB,即使我分配的只有4k块。
I found that there is a manifest attribute I can add to the application tag, android:largeHeap="true"
but it apparently wasn't added until API level 11, and I need to target API level 8. 我发现有一个清单属性我可以添加到应用程序标签,
android:largeHeap="true"
但显然直到API级别11才添加,我需要针对API级别8。
Yet I know this is possible somehow because Firefox regularly takes 60-80MB of RAM, which is 2-3x what my test app is able to take. 但我知道这可能是某种方式,因为Firefox通常需要60-80MB的RAM,这是我的测试应用程序能够承担的2-3倍。
The only way to allocate more than the heap limit on a device is to allocate outside the heap. 在设备上分配超过堆限制的唯一方法是在堆外部进行分配。 That is to say, you'll need to use the NDK to allocate more memory to your app, which is what Firefox does.
也就是说,您需要使用NDK为您的应用分配更多内存,这正是Firefox所做的。
Apart from that, you cannot allocate more. 除此之外,你不能分配更多。 In 99% of the cases, you don't need to allocate more.
在99%的情况下,您不需要分配更多。 You just need to use more efficiently what you have.
你只需要更有效地使用你拥有的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.