如何增加一个Android应用程序的堆大小? [英] How to increase heap size of an android application?

查看:112
本文介绍了如何增加一个Android应用程序的堆大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个Android应用程序,它使用多个3D模型。这种带有纹理的模型,会占用大量的内存。我发现了制造商设置的堆大小的应用程序可以使用的限制。例如我的平板电脑三星Galaxy Tab 8.9 P7310可以占用64MB内存。

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 heap size an application can use. For example my tablet Samsung Galaxy Tab 8.9 P7310 can take up 64MB of memory.

有没有办法来增加内存的应用程序可以使用这个尺寸?

Is there a way to increase this size of memory an application can use?

推荐答案

您可以使用<一个href="http://developer.android.com/reference/android/R.styleable.html#AndroidManifestApplication_largeHeap">android:largeHeap="true"要求更大的堆大小,但是这不会工作在任何pre蜂窝设备。在pre 2.3装置,您可以使用VMRuntime类,但是这不会对工作姜饼及以上。

You can use android:largeHeap="true" to request a larger heap size, but this will not work on any pre Honeycomb devices. On pre 2.3 devices, you can use the VMRuntime class, but this will not work on Gingerbread and above.

只有这样,才能有大的限制是尽可能做到通过NDK内存密集型任务,如NDK不征收内存限制类的SDK。

The only way to have as large a limit as possible is to do memory intensive tasks via the NDK, as the NDK does not impose memory limits like the SDK.

另外,你可以只加载模式,目前在考虑的一部分,因为你需要它,而从内存中删除未使用的部分加载休息。但是,这是不可能的,这取决于你的应用程序。

Alternatively, you could only load the part of the model that is currently in view, and load the rest as you need it, while removing the unused parts from memory. However, this may not be possible, depending on your app.

这篇关于如何增加一个Android应用程序的堆大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆