Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To expand upon CommonsWare's answer:</p> <blockquote> <p>I have no idea if this works, but you might try <a href="http://developer.android.com/reference/java/lang/Thread.html#setDefaultUncaughtExceptionHandler%28java.lang.Thread.UncaughtExceptionHandler%29" rel="noreferrer">adding a top-level exception handler</a>, and in there <a href="http://developer.android.com/reference/android/os/Debug.html#dumpHprofData%28java.lang.String%29" rel="noreferrer">asking for a heap dump</a> if it is an <code>OutOfMemoryError</code>.</p> </blockquote> <p>I followed his suggestion successfully in my own Android app with the following code:</p> <pre><code>public class MyActivity extends Activity { public static class MyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { @Override public void uncaughtException(Thread thread, Throwable ex) { Log.e("UncaughtException", "Got an uncaught exception: "+ex.toString()); if(ex.getClass().equals(OutOfMemoryError.class)) { try { android.os.Debug.dumpHprofData("/sdcard/dump.hprof"); } catch (IOException e) { e.printStackTrace(); } } ex.printStackTrace(); } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Thread.currentThread().setUncaughtExceptionHandler(new MyUncaughtExceptionHandler()); } } </code></pre> <p>After the dump is created, you need to copy it from your phone to your PC: Click "Turn on USB storage" on the phone, find the file and copy it to your hard drive.</p> <p>Then, if you want to use the Eclipse Memory Analyzer (MAT) to analyze the file, you will need to covert the file: <code>hprof-conv.exe dump.hprof dump-conv.hprof</code> (hprof-conv is located under <code>android-sdk/tools</code>)</p> <p>Finally, open the <code>dump-conv.hprof</code> file with MAT</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload