在Android Stresstest内存 [英] Stresstest Memory on Android

查看:280
本文介绍了在Android Stresstest内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能stresstest的Andr​​oid系统,以检查是否可用内存减少会发生什么(并为此哪些应用程序被杀害,...)。

Is it possible to stresstest an Android system to check what happens if available memory decreases (and therefor which applications are killed, ...).

我现在有一个测试的应用程序,在矢量分配定期10MB。但是,一个内存溢出异常被抛出达到了500MB。但是被测系统没有充分的影响。我需要将收购更多的内存。

I currently have a testing application that periodically allocates 10MB in a vector. But an OutOfMemory exception is thrown reaching 500MB. But the system under test was not influenced sufficiently. I need to aquire even more memory.

存在任何已知库/程序来使用,还是有让应用程序使用的内存大于500MB任何其它方法。

Are there any known libraries/programs to use or is there any other method that let an application use more memory than 500MB.

添加:我已经使用的android:largeHeap =真正的在我的清单。

Add: I'm already using android:largeHeap="true" in my manifest.

推荐答案

除了生根设备和黑客的Andr​​oid分配的内存限制运行的应用程序的方式,有没有办法使用本地Java $ C来增加内存的限制$ C。

Other than rooting the device and hacking the way Android allocates a memory limit to running applications, there is no way to increase the limit of memory using native Java code.

但是(!),使用C ++库通过JNI允许你绕过这个限制。在这一层上分配的所有内存访问该设备的整体内存池,而不是沙盒池本机应用程序获得。

However(!), using a C++ library via JNI allows you to circumvent this limitation. All memory allocated on this layer has access to the overall memory pool of the device, rather than the sandboxed pool native applications get.

对于这样的一个例子,看看OpenGL的。通常情况下,你也许可以容纳4-5位图在内存大小1024×1024得到一个内存不足异常之前。但是,如果每次创建位图,你把它改造成一个OpenGL纹理(这是在本地C ++库管理),然后销毁位图,你会发现,你可以到达前持有庞大的图片数量的设备内存限制​​。

As an example for this, look at OpenGL. Normally, you could maybe hold 4-5 bitmaps sized 1024x1024 in memory before getting an OutOfMemory exception. However, if each time you create a bitmap, you transform it into an OpenGL texture (which is managed in the native C++ library) and then destroy the bitmap, you'll find that you can hold a huge amount of pictures before reaching the device's memory limit.

同样,如果您创建一个这样的C ++库,并将其链接到通过JNI项目,理论上可以存放库中一个巨大的缓冲区,使用Java code追加更多的数据,或提取一部分在需要时数据。

Similarly, if you create such a C++ library, and link it to your project via JNI, you could theoretically hold a massive buffer inside the library, and use the Java code to append more data, or extract a portion of the data when needed.

这篇关于在Android Stresstest内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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