Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6223163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:26:26+00:00 2026-05-24T08:26:26+00:00

The sun JVM supports a -XX:+HeapDumpOnOutOfMemoryError option to dump heap whenever a java process

  • 0

The sun JVM supports a -XX:+HeapDumpOnOutOfMemoryError option to dump heap whenever a java process runs out of heap.

Is there a similar option on Android that will make an android app dump heap on an OutOfMemoryException? It can be difficult to try to time it properly when using DDMS manually.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:26:27+00:00Added an answer on May 24, 2026 at 8:26 am

    To expand upon CommonsWare’s answer:

    I have no idea if this works, but you might try adding a top-level exception handler, and in there asking for a heap dump if it is an OutOfMemoryError.

    I followed his suggestion successfully in my own Android app with the following 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());
        }
    }
    

    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.

    Then, if you want to use the Eclipse Memory Analyzer (MAT) to analyze the file, you will need to covert the file: hprof-conv.exe dump.hprof dump-conv.hprof (hprof-conv is located under android-sdk/tools)

    Finally, open the dump-conv.hprof file with MAT

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Switching from JVM 1.4 to 1.5 has performance benefits as per release notes. http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#performance
check the following program: Run it in sun java hostspot jvm, everything will be
the jvm spec version 2: http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html seems quite old. java has been release new
I'm running a small minecraft server with this command: /usr/lib/jvm/java-6-sun/bin/java -Xmx2048M -Xms2048M -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalPacing
This problem is specifically about Sun Java JVM running on Linux x86-64 . I'm
In the Sun JVM, classes that are loaded by the class loader are put
Assuming we always use a Sun JVM (say, 1.5+), is it always safe to
I've often read that in the Sun JVM short-lived objects (relatively new objects) can
Should I stick with Sun's Java code conventions for PHP code?
Using the Sun Java VM 1.5 or 1.6 on Windows, I connect a non-blocking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.