Created
January 5, 2017 18:03
-
-
Save garethahealy/e911dcdbe9b7b1ccaae1737b69060d78 to your computer and use it in GitHub Desktop.
java heapdump for docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
docker exec $1 ps -deaf | |
echo -n "PID for Java: " | |
read pid | |
docker exec $1 jcmd $pid GC.heap_dump /tmp/docker.hprof | |
docker cp $1:/tmp/docker.hprof . | |
docker exec $1 rm /tmp/docker.hprof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Thanks, for sharing this!.
jcmd throws error complaining about /tmp/docker.hprof. So line 8 should be like below:
docker exec $1 sh -c 'jcmd $pid GC.class_histogram > /tmp/docker.hprof'