DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Viewing hprof From Android With JVisualVM

Viewing hprof From Android With JVisualVM

Peter Karussell user avatar by
Peter Karussell
·
Apr. 11, 11 · Java Zone · Interview
Like (0)
Save
Tweet
10.89K Views

Join the DZone community and get the full member experience.

Join For Free
  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/

Android (robot) app Memory (storage engine) Manifest (transportation) Convert (command) Dump (program)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Exporting and Importing Projects in Eclipse
  • Flutter vs React Native. How to Cover All Mobile Platforms in 2022 With No Hassle
  • Pre-Commit Hooks DevOps Engineer Should Know To Control Kubernetes
  • What SREs Can Learn From the Atlassian Nightmare Outage of 2022

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo