1

Suddenly my app crash and pop this error out...any idea for this error ? tried so hard still can't solve...

Clamp target GC heap from 111MB to 96MB Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 2.380ms total 71.136ms

Throwing OutOfMemoryError "Failed to allocate a 14710 byte allocation with 12888 free bytes and 12KB until OOM

AndroidRuntime: Error reporting crash
              java.lang.OutOfMemoryError: Failed to allocate a 14710 byte allocation with 12888 free bytes and 12KB until OOM
                  at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
                  at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:125)
                  at java.lang.StringBuffer.append(StringBuffer.java:278)
                  at java.io.StringWriter.write(StringWriter.java:123)
                  at com.android.internal.util.FastPrintWriter.flushLocked(FastPrintWriter.java:358)
                  at com.android.internal.util.FastPrintWriter.appendLocked(FastPrintWriter.java:303)
                  at com.android.internal.util.FastPrintWriter.write(FastPrintWriter.java:625)
                  at com.android.internal.util.FastPrintWriter.append(FastPrintWriter.java:658)
                  at java.io.PrintWriter.append(PrintWriter.java:691)
                  at java.io.PrintWriter.append(PrintWriter.java:31)
                  at java.lang.Throwable.printStackTrace(Throwable.java:324)
                  at java.lang.Throwable.printStackTrace(Throwable.java:300)
                  at android.util.Log.getStackTraceString(Log.java:509)
                  at com.android.internal.os.RuntimeInit.Clog_e(RuntimeInit.java:59)
                  at com.android.internal.os.RuntimeInit.access$200(RuntimeInit.java:43)
                  at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:91)
                  at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
                  at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)

I've tried something like this, this and this, but it doesn't work.

Can anyone help me to solve it? I really appreciate it.

Thanks!

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Valor
  • 11
  • 4
  • 1
    What does your code look like? Only post the relevant parts (code which gets executed when this error happens) – Zun Oct 11 '18 at 07:19
  • there is some problem with your code obviously. It is leaking memory likely. – Vladyslav Matviienko Oct 11 '18 at 07:30
  • Welcome to Stack Overflow! Please read "How to create a [mcve]". Then use the [edit] link to improve your question (do not add more information via comments). Otherwise we are not able to answer your question and help you. – GhostCat Oct 11 '18 at 07:36
  • Note that your `java.lang.OutOfMemoryError` occurred within `Throwable.printStackTrace`, read, while attempting to print another exception or error. That other throwable could also be an `OutOfMemoryError`, but it could also something else. – Holger Oct 11 '18 at 09:26
  • you are running out of memory. either reduce memory useage or check for memory leaks, recursive calls etc... – lumo Oct 11 '18 at 15:11

1 Answers1

1

In your Manifext.xml add this line android:largeHeap="true" it will allocate a large heap memory.

<application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"

        android:largeHeap="true"

        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/MyAppTheme">
...
</application>

I hope this will work for you.

Try to use Debugger and Android Profiler to detect where exactly resources are used to improve the performance.

Harish Kamboj
  • 887
  • 12
  • 32