I’m having a massive memory issue on specific devices where a ton of memory is allocated out of nowhere. I’m trying to do a heapdump to figure out what is allocating the memory, but when I attempt to open the heapdump file, I get an error in Android Studio:
HprofView - Unexpected error while processing hprof file: null
I’ve done some web searching, but there aren’t any references to this error as far as I can tell. I just need help getting the heap dump, I can fix my app from there.
Edit: I tried converting the dump file, but it gave me another error:
Convert Android Java Heap Dump - Unexpected error while converting heap dump: ERROR: read 16710959 of 33177623 bytes
I can’t give a definitive answer, but in my experience it seems to happen when the app is close to its memory usage limit. This is obviously not ideal when you’re trying to debug an
2 things I can suggest to get around the problem:
- Try using a different device/emulator. e.g. I’ve found this issue is quite common on my Samsung S5, but happens less often on my Nexus 4.
- Pause the application some time before it runs out of memory, then get the heap dump at that point. This isn’t ideal, but memory leaks tend to cause a problem over time, rather all at once, so you should still be able to diagnose the leak.