Skip to content

Instantly share code, notes, and snippets.

View sureshnepolian's full-sized avatar
👨‍💻

sureshnepolian

👨‍💻
View GitHub Profile
@sureshnepolian
sureshnepolian / ConsumeHeap.java
Created October 20, 2020 09:51 — forked from mosheeshel/ConsumeHeap.java
Function to fill JVM/Java Heap, Java options to automatically create a Heapdump on that event and a companion script to upload resulting files to S3
import java.io.IOException;
import java.util.Vector;
/**
* Created by moshee
* on: 07/06/17
* to compile in place: `javac ConsumeHeap.java`
* Execute: `java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/app-`date +%s`-pid$$.hprof -XX:OnOutOfMemoryError=/opt/app/bin/upload_dump_s3.sh -Xmx2m ConsumeHeap`
* HeapDumpOnOutOfMemoryError specifies to automatically create a dump when OOM occures
* HeapDumpPath supplies a path to put that file