ThreadDump / HeapDump / GC Log

Published by

on

PLEASE NOTE: Getting thread dump and heap dump are stop the world operations.


How to get thread dump

  1. Confirm the server isn’t getting more requests
    • Either detach from application load balancer or block from getting new requests
  2. Get java process ID using jps
    • jps -v
  3. Use jstack to get thread dump file
    • jstack -l $PID >> threaddump.log
  4. Analyze from https://fastthread.io/

How to get heap dump

  1. Confirm the server isn’t getting more requests
    • Either detach from application load balancer or block from getting new requests
  2. Get java process ID using jps
    • jps -v
  3. Use jmap to get heap dump file
    • jmap -dump:format=b,file=headump.hprof $PID
  4. (Recommended) Zip the .hprof file into .tar.gz
  5. Analyze from MAT(Eclipse Memory Analyzer) or https://heaphero.io or https://www.yourkit.com/

How to generate gc.log

  1. To generate gc.log, need to add JVM start-up arguments
  2. Analyze from https://gceasy.io/
-verbose:gc -Xloggc:${LOG_PATH}/gc/gc.`date '+%Y%m%d%H%M'`.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps

How to make a file into .tar.gz file

tar -zcvf [FILE_NAME.tar.gz] [FILE_NAME]
ex) tar -zcvf aaa.tar.gz abc

tar -cvf [FILE_NAME.tar] [FILE_NAME]
ex) tar -cvf aaa.tar abc

Leave a comment