14

Until yesterday my Application worked fine, But what I did is, due to some reasons I had to open same Application with different work space in Android Studio. From then when I try to run the App I'm getting following exception, So I've removed newly created works pace but still I'm stuck with the following fat exception.

 Throwing   OutOfMemoryError "Failed to allocate a 170 byte allocation with 74 free bytes and 74B until OOM" (recursive case)
"main" prio=5 tid=1 Runnable
| group="main" sCount=0 dsCount=0 obj=0x74430970 self=0xb4606800
| sysTid=1905 nice=0 cgrp=apps sched=0/0 handle=0xb777c160
| state=R schedstat=( 0 0 0 ) utm=83 stm=36 core=0 HZ=100
| stack=0xbf15b000-0xbf15d000 stackSize=8MB
| held mutexes= "mutator lock"(shared held)
at java.lang.String.<init>(String.java:233)
at java.lang.String.<init>(String.java:191)
at java.io.ByteArrayOutputStream.toString(ByteArrayOutputStream.java:175)
at java.util.jar.ManifestReader.readValue(ManifestReader.java:181)
at java.util.jar.ManifestReader.readHeader(ManifestReader.java:107)
at java.util.jar.ManifestReader.readEntries(ManifestReader.java:59)
at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:311)
at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:268)
at java.util.jar.JarFile.getInputStream(JarFile.java:380)
at libcore.net.url.JarURLConnectionImpl.getInputStream(JarURLConnectionImpl.java:222)
at java.net.URL.openStream(URL.java:470)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:444)
at java.lang.Class.getResourceAsStream(Class.java:1334)
at com.google.m.a.a.a.a(unavailable:-1)
at com.google.m.a.a.a.a(unavailable:-1)
at com.google.maps.api.android.lib6.b.e.<init>(unavailable:-1)
at com.google.maps.api.android.lib6.b.e.<init>(unavailable:-1)
at com.google.maps.api.android.lib6.b.e.a(unavailable:-1)
at com.google.maps.api.android.lib6.c.dz.a(unavailable:-1)

 [ 03-30 11:13:03.162  1905: 1914 I/art      ]
Clamp target GC heap from 64MB to 64MB

--------- beginning of crash
03-30 11:13:03.179    1905-1905/com.example.myothermap E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.myothermap, PID: 1905
java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack available

How can I recover from this?

Zoe
  • 23,712
  • 16
  • 99
  • 132
Kishore Kumar Korada
  • 1,184
  • 3
  • 19
  • 42

2 Answers2

0

Add this line in the Manifest file of your project inside the Application tag.

android:largeHeap="true"

like this

<application
    android:largeHeap="true"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar" >
  • 1
    The use of largeHeap is not recommended in all cases, please use it very cautiously, it might slow other running application, and also impact your app's reactiveness, since the garbage collector with be solicited more often. For more information check this speech from google i/o https://www.youtube.com/watch?v=_CruQY55HOk – Mood Jul 17 '15 at 12:47
  • 5
    @Mood has pointed out correctly. This answer will do more damage than solution. – divyenduz Jul 20 '15 at 07:41
0

Try adding this to your build gradle:

Add this code inside the Android tag

dexOptions {
    javaMaxHeapSize "4g"
}
Filnor
  • 1,253
  • 2
  • 22
  • 27
  • hey thanks for the suggestion. I would be happy to try it but in my case the error comes from a big image that we draw. Do you think it will still work ? Because the "android:largeHeap="true"" config cannot prevent this crash – jeevium Jan 11 '19 at 09:28
  • Using largeHeap isn't always recommended. It would do more problems than having a solution. maxHeapSize should work for you. Let me know if it does – Trent Orense Jan 13 '19 at 09:11
  • 4
    It's a runtime crash, it has nothing to do with memory at compile time – Zoe Apr 21 '19 at 20:02