



Adding this option is essential to production systems since out of memory could take a long time to happen. So, to enable this feature, add XX:+HeapDumpOnOutOfMemoryError to the JVM startup options.

Sun HotSpot JVM has a way to instruct the JVM to dump its heap state when the JVM runs out of memory into a file. So, the best way to handle OOMs is to let the JVM dump a heap file of the state of the memory of the JVM when it went out of memory. Setting Up the Application Ready for Heap AnalysisĪny non-deterministic or sporadic problems like an out of memory error would be a challenge to do any post-mortem on. Analyzing out of memory issues with a heap analyzer, specifically with this great open source project: Eclipse MAT.Understanding the type of memory issue the application is suffering from.Getting a heap dump from a Java process when it goes out of memory.With this prelude, we will focus on the following: So, what is the more methodical approach to understanding the programming problem related to a memory problem? This is answered by understanding the memory heap of applications and the distribution when the out of memory happens. Without understanding what caused the heap usage inflation or spike, memory usage stability (hence application stability) is not guaranteed. Any attempts to restart the application - even with more max memory (-Xmx option) - is not a long-term solution. The worst part of this specific condition is that the application cannot recover and will crash. That leads to an over-usage of the heap memory allocated and hence an "out of memory" condition. Specifically, in the memory dimension, when this is unpredictable or is spiky, more than the recommended memory is being allocated to the application. If we recall, every application has a worst-case performance. To understand this, we have to go back to the computer science fundamentals of the complexity of algorithms, specifically "space" complexity.
Java memory disk map software#
Any software developer who has worked with Java-based enterprise-class backend applications would have run into this infamous or awkward error from a customer or QA engineer: : Java heap space.
