Skip to content

Instantly share code, notes, and snippets.

View lamngockhuong's full-sized avatar
🍊
Working

Lâm Ngọc Khương lamngockhuong

🍊
Working
View GitHub Profile
@lamngockhuong
lamngockhuong / ConsumeHeap.java
Created May 3, 2019 07:19 — 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