title: Failed to allocate a 27394783 byte allocation with 15063472 free bytes and 14MB until OOM exception
body: <h1>Scenario</h1>
  
  <p>I am working on android application which downloads encrypted video file, save it in memory and then decrypt it when user click on play button of that file from the android application. And after decryption play that video.</p>
  
  <h1>Problem</h1>
  
  <p>App works fine in most of the devices. But in Redmi note 4 (as per my testing on 3 different redmi note 4)it gives exception</p>
  
  <pre><code>Throwing OutOfMemoryError "Failed to allocate a 27394783 byte allocation with 15063472 free bytes and 14MB until OOM
  </code></pre>
  
  <h1>Android Menifest.xml</h1>
  
  <pre><code>    android:name=".receiver.ConnectivityListener"
      android:allowBackup="true"
      android:hardwareAccelerated="false"
      android:largeHeap="true"
      android:supportsRtl="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/MyMaterialTheme"
      android:usesCleartextTraffic="true"
  </code></pre>
  
  <h1>In build.gradle</h1>
  
  <pre><code>dexOptions {
      incremental true
      javaMaxHeapSize "4g"
      preDexLibraries true
      dexInProcess = true
  }
  </code></pre>
  
  <h1>logcat</h1>
  
  <pre><code>2020-03-21 15:23:40.733 19593-19699/com.ehiddenbrain.prod I/art: Forcing collection of SoftReferences for 26MB allocation
  2020-03-21 15:23:40.733 19593-19699/com.ehiddenbrain.prod I/art: Starting a blocking GC Alloc
  2020-03-21 15:23:40.767 19593-19699/com.ehiddenbrain.prod I/art: Clamp target GC heap from 513MB to 512MB
  2020-03-21 15:23:40.767 19593-19699/com.ehiddenbrain.prod I/art: Alloc concurrent mark sweep GC freed 3(72B) AllocSpace objects, 0(0B) LOS objects, 2% free, 497MB/512MB, paused 435us total 33.194ms
  2020-03-21 15:23:40.767 19593-19699/com.ehiddenbrain.prod W/art: Throwing OutOfMemoryError "Failed to allocate a 27394783 byte allocation with 15063472 free bytes and 14MB until OOM"
  
  
  2020-03-21 15:23:40.778 19593-19699/com.ehiddenbrain.prod E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #9
  Process: com.ehiddenbrain.prod, PID: 19593
  java.lang.RuntimeException: An error occurred while executing doInBackground()
      at android.os.AsyncTask$3.done(AsyncTask.java:318)
      at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
      at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
      at java.util.concurrent.FutureTask.run(FutureTask.java:242)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
      at java.lang.Thread.run(Thread.java:760)
   Caused by: java.lang.OutOfMemoryError: Failed to allocate a 27394783 byte allocation with 15063472 free bytes and 14MB until OOM
      at com.android.org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher.engineDoFinal(BaseBlockCipher.java:1112)
      at javax.crypto.Cipher.doFinal(Cipher.java:2056)
      at com.example.ehiddenbrain_v03.utility.Decoder.decryptVideo(Decoder.java:56)
      at com.example.ehiddenbrain_v03.background.DecoderBackgroundTask.doInBackground(DecoderBackgroundTask.java:66)
      at com.example.ehiddenbrain_v03.background.DecoderBackgroundTask.doInBackground(DecoderBackgroundTask.java:26)
      at android.os.AsyncTask$2.call(AsyncTask.java:304)
      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
      at java.lang.Thread.run(Thread.java:760) 
  2020-03-21 15:23:40.779 19593-19699/com.ehiddenbrain.prod W/AndroidRuntime: finished raiseRlimit, rlim_cur:4096  rlim_max:4096
  2020-03-21 15:23:40.945 19593-19696/com.ehiddenbrain.prod V/FA: Recording user engagement, ms: 4696
  2020-03-21 15:23:40.947 19593-19696/com.ehiddenbrain.prod V/FA: Activity paused, time: 240603587
  </code></pre>
  
  <p>If anyone know about this issue please help me ...
  Thanks !!!</p>