This project contains a Bash script (auto_dump.sh
) that monitors the heap memory usage of a Java service/container and triggers a heap dump if the usage exceeds a specified threshold.
This script was developed to address scenarios where the -XX:+HeapDumpOnOutOfMemoryError
option might not be sufficient.
By running as a sidecar container, it proactively monitors heap memory usage and triggers a heap dump when the usage exceeds a specified threshold.
This ensures that heap dumps are captured reliably, even in complex environments.
- Monitors heap memory usage of a Java process.
- Triggers a heap dump when heap usage exceeds the defined threshold.
- Runs the check in a continuous loop with a configurable interval.
- Bash shell
- Java Development Kit (JDK) with
jcmd
tool pgrep
command
-
Set the Threshold: Modify the
THRESHOLD
variable in the script to set the desired heap usage percentage threshold. The default is 95%.THRESHOLD=95
-
Run the Script: Execute the script to start monitoring the heap memory usage.
./auto_dump.sh
This project is licensed under the GNU General Public License v2.0. You may obtain a copy of the License at: