Viewing hprof From Android With JVisualVM
Join the DZone community and get the full member experience.
Join For Free-
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/
Android (robot)
app
Memory (storage engine)
Manifest (transportation)
Convert (command)
Dump (program)
Opinions expressed by DZone contributors are their own.
Comments