Agent Heap Storage Monitoring and Shutdown
The Java Agent monitors the heap storage used by the instrumented application and shuts itself down when conditions indicate excessive utilization of Java heap storage by the application. The agent takes this measure not necessarily because it is likely to be the source of the memory pressure—in fact, it can help you diagnose the root cause of the issue—but as a final protective measure to help relieve the pressure on available memory for the application.
Typical reasons for excessive heap utilization include:
- Java heap space is too small compared to your application traffic and footprint
- Java heap memory leak
- A rogue thread is consuming a large amount of memory in a short amount of time
Java Agent monitoring of heap storage works as follows. The agent check heap utilization every 30 seconds. When it detects that heap utilization has exceeded 95%, the Java Agent checks for a garbage collection event. When garbage collection occurs, it checks heap utilization again. If usage still exceeds the threshold, the agent shuts itself down and logs the following agent event:
ERROR HeapShortageMonitor - Agent shutdown triggered because max heap usage percentage reached
If heap memory utilization exceeds the threshold, but garbage collection never occurs, the agent resumes normal monitoring after 30 seconds. If the heap usage remains above the threshold, the heap shortage monitor resumes checking for garbage collection, as it did previously.
You can use a Java Agent node property to control whether heap storage monitoring is enabled and the action that results from excessive heap utilization. The heap-storage-monitor-enabled controls whether it is enabled (true, by default), and the heap-storage-monitor-shutdown-action property determines the triggered action, between:
- true: If the heap threshold is exceeded, the agent is disabled.
- false: If the threshold is exceeded, a warning-level message is written to the agent log and warning event is sent to the Controller (of type AGENT_EVENT with the text: "AppDynamics agent has detected shortage of JVM Heap Storage").