Viewing hprof From Android With JVisualVM
- Add an additional permission to your app
<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />
to your manifest - Create hprof
protected void onDestroy() {or alternatively create a hprof file with:
super.onDestroy();
try {
Debug.dumpHprofData(“/sdcard/data.hprof”);
} catch (Exception e) {
Log.e(“xy”, “couldn’t dump hprof”);
}
}adb shell ps | grep yourpackage; adb shell kill -10 pid
- Get the hprof file
android-sdk-linux_x86/platform-tools/adb pull /sdcard/data.hprof /tmp/ - Convert the hprof to sun standard format
android-sdk-linux_x86/tools/hprof-conv /tmp/search.hprof /tmp/search.st.hprof
- 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/
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)
Tags:





