Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 2.1.2 'Dump Java Heap' Not working (Mac OS El Capitan)

I am trying to get an .hprof file using the 'dump java heap' button in Android Studio memory monitor, but for some reason no .hprof file is generated. Does anybody know why? Allocation Tracking works okay.

like image 767
codename_47 Avatar asked Jul 18 '16 06:07

codename_47


People also ask

How do I fix out of memory error in Android Studio?

If you haven't yet encountered an OOM in your Android application, you will in the near future. Memory leaks cause the OutOfMemoryError in Android. To eliminate the OutOfMemoryError, you must first eliminate memory leaks from your Android application. The Error!

How do I get rid of heap dump on memory error?

In order to capture a heap dump automatically, we need to add the HeapDumpOnOutOfMemoryError command-line option that generates a heap dump when a java. lang. OutOfMemoryError is thrown.

What is maximum heap size in Android Studio?

By default, Android Studio has a maximum heap size of 1280MB. If you are working on a large project, or your system has a lot of RAM, you can improve performance by increasing the maximum heap size for Android Studio processes, such as the core IDE, Gradle daemon, and Kotlin daemon.


1 Answers

It does not work for me either, on Android Studio v2.3.3 on Linux. It is a silent failure with no log or error that I can find. This workaround works on my system:

adb [-d|-e] shell am dumpheap <package-name> /sdcard/heapdump.nhprof
adb [-d|-e] pull /sdcard/heapdump.nhprof
<path-to-AndroidSDK>/platform-tools/hprof-conv heapdump.nhprof heapdump.hprof

And then you can drag the heapdump.hprof file onto Android Studio and it will analyze and display it. Choose -d or -e depending whether you are using a USB connected device, or the emulator. Replace with your package name (usually starts with com. or org. )

like image 88
kshepherd Avatar answered Sep 19 '22 12:09

kshepherd