When your app starts eating up heap, it’s time to break out the diagnostics.
Steps:
- Collect heap dumps with
-XX:+HeapDumpOnOutOfMemoryError
- Use Eclipse MAT to analyze retained sets
- Identify leak suspects and dominator treesIn our case, an executor service wasn’t being shut down — held on to task references.
Memory leaks love long-lived services. Clean up after yourself.