10 Investigating memory issues with heap dumps
This chapter covers
- Obtaining heap dumps for an app execution
- Using heap dumps to investigate memory allocation problems
- Using OQL to query object instances in heap dumps
- Using AI to simplify your heap dump investigation
When you’re testing the app, you can profile it to spot any memory-hungry capabilities that need optimization. But what if the app doesn’t give you that luxury? What if it crashes spectacularly before you can even lift a profiler?
In many cases, crashes are the tragic result of memory allocation issues, with the usual suspect being memory leaks. These leaks happen when an app clings to objects in memory like a hoarder refusing to throw anything away—even when it has no use for them anymore. Over time, the memory fills up, and eventually, the JVM throws in the towel, leaving you with the dreaded OutOfMemoryError.
Think of it like a messy office. If you keep piling up papers, coffee cups, and half-eaten snacks without ever cleaning up, at some point, you’ll run out of space to work. In the digital world, instead of an exasperated coworker staging an intervention, your app simply crashes and burns.