Android/Java 使用 cipher.getOutputSize() 分配字节时内存不足 "OutOfMemoryError"

标签 android arrays out-of-memory aes bouncycastle

我在使用 Bouncy caSTLe 的 Aes 中解密功能时遇到问题。

我有一个常规的加密/解密函数,但是太慢了。现在我尝试使用 BouncyCaSTLe 库中测试文件示例的部分代码来解决此问题。我写了这样的代码:

http://www.java2s.com/Tutorial/Java/0490__Security/SymmetricencryptionexamplewithpaddingandCBCusingDESwiththeinitializationvectorinline.htm

现在我收到一个错误

"E/dalvikvm-heap(548): Out of memory on a 52023154-byte allocation."

Caused by: java.lang.OutOfMemoryError when try to allocate byte[] plainText.

我对大小为 1-2 MB 的文件没有问题,但在大于 2MB 的文件上会出现此错误。

我对此没有任何想法,也没有在网络上找到任何回复。你能帮我吗?

最佳答案

我在这篇文章中找到了解决方案: How to change the android emulator RAM size from the command line? 通过这次升级我的堆大小!感谢社区!

关于Android/Java 使用 cipher.getOutputSize() 分配字节时内存不足 "OutOfMemoryError",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13614062/

相关文章:

java - 处理 "Activity has been destroyed"(java.lang.IllegalStateException) 异常?

java - 为什么 Google map Gocode 在我的 Android 设备上(而不是在浏览器上)返回零结果

javascript - jquery比较数组并返回不相同的值

PHP MySQL 在数组中选择数组

c# - Android 上的 Xamarin.Forms ListView OutOfMemoryError 异常

android - 用户身份验证不会保留在 WebView 上

安卓网络服务认证

arrays - 如果只允许单位移位,则计算对数组进行排序的移动次数

java - 解码位图时出现 OutOfMemory 异常

c# - Entity Framework 6 内存使用量达到 2GB