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.
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!
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.
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.
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. )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With