Search code examples
androidarraysout-of-memoryaesbouncycastle

Android/Java Out of memory on a -byte allocation with cipher.getOutputSize() "OutOfMemoryError"


I have a problem with a function of Decrypt in Aes with Bouncy castle.

I have a regular function to encrypt/decrypt, but is too slow. Now I am trying to fix this problem using a part of code of an example of the test file in the BouncyCastle' Lib. I write a code like this:

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

Now I receive an error

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

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

I have no problem with file of size 1-2 MB, but on a file larger than 2MB is there this error.

I don't have any idea for this and haven't find any response on web. Can you help me?


Solution

  • I have found a solution in this post: How to change the android emulator RAM size from the command line? With this upgrade my heap size! thanks to the comunity!