简体   繁体   English

如何在Android应用程序中分配超过25MB,api等级8?

[英]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.

相关问题 如何在外部应用程序或Webview中打开pdf文件大小大于25mb - How to open pdf file in external app or in webview size is greater than 25mb 在Android中,如何关闭后台的android应用程序数量达到所需的ram,例如25mb - In Android, How do I close the number of android applications in the background amounting to the required ram e.g. 25mb 我如何在我的Android cocos2d项目中使用mp3声音,以免将apk的大小增加到25MB - How can I use mp3 sounds in my Android cocos2d project so as to not increase the size of apk to 25MB 在Android上分配512MB以上的RAM - Allocate more than 512mb ram on android 如何在AVD上分配超过1024 MB的RAM? - How can I allocate more than 1024 MB RAM on AVD? Android PlayStore 警告您的应用当前针对 API 级别 25 - Android PlayStore warning your app currently targets API level 25 如何在API级别25及以下的Android中为视图充气? - How to inflate a view in android in API level 25 and below? 如何测试和部署资产超过 150 MB 的 Flutter 应用程序? - How to test and deploy a Flutter app with more than 150 MB of assets? 如何在大于 25 的 API 版本中在 android 中设置启动器图标 - How to set launcher icon in android in API version greater than 25 Broadcastreceiver无法在android Nougat API 25级中工作吗? - Broadcastreceiver not working in android Nougat api level 25?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM