Over a million developers have joined DZone.

Viewing hprof From Android With JVisualVM

· Java Zone

Discover how AppDynamics steps in to upgrade your performance game and prevent your enterprise from these top 10 Java performance problems, brought to you in partnership with AppDynamics.

  1. Add an additional permission to your app
    <uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />
    to your manifest
  2. Create hprof
    protected void onDestroy() {
    super.onDestroy();
    try {
    Debug.dumpHprofData(“/sdcard/data.hprof”);
    } catch (Exception e) {
    Log.e(“xy”, “couldn’t dump hprof”);
    }
    }
    or alternatively create a hprof file with:
    adb shell ps | grep yourpackage; adb shell kill -10 pid
  3. Get the hprof file

    android-sdk-linux_x86/platform-tools/adb pull /sdcard/data.hprof /tmp/
  4. Convert the hprof to sun standard format
    android-sdk-linux_x86/tools/hprof-conv /tmp/search.hprof /tmp/search.st.hprof
  5. Open hprof with /usr/lib/jvm/java-6-sun/bin/jvisualvm
    File -> Load -> Head dumps (hprof)

 

Avoid memory leaks -> take a look at the trackbacks!

 

From http://karussell.wordpress.com/2011/04/10/viewing-hprof-from-android-with-jvisualvm/

The Java Zone is brought to you in partnership with AppDynamics. AppDynamics helps you gain the fundamentals behind application performance, and implement best practices so you can proactively analyze and act on performance problems as they arise, and more specifically with your Java applications. Start a Free Trial.

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}