Skip to content

Instantly share code, notes, and snippets.

@paveljurca
Last active May 3, 2023 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paveljurca/a13f14d893277452496b75063efe081c to your computer and use it in GitHub Desktop.
Save paveljurca/a13f14d893277452496b75063efe081c to your computer and use it in GitHub Desktop.
How to debug running Java application

How to debug running Java application

GC tunning https://developers.redhat.com/articles/2021/11/02/how-choose-best-java-garbage-collector#garbage_first__g1__collector

jvm memory profiling tools https://www.baeldung.com/java-profilers

  • swapon --summary
  • vmstat 1
  • free -m
  • cat /proc/meminfo
  • sar -r (memory report)
  • sar -S (swap report)
  • ps -eo comm,etime,user | grep java
  • pstack or gstack for CPU debugging (ie Apache HTTPD high CPU on RHEL - Red Hat Customer Portal)
  • top -b
  • jstack

standard JVM monitoring tools https://docs.oracle.com/javase/8/docs/technotes/tools/unix/s9-monitoring-tools.html#sthref282

standard JVM debugging tools https://docs.oracle.com/javase/8/docs/technotes/tools/unix/s11-troubleshooting_tools.html#sthref327

# total_java_processes_size
env PID=$(cat PID_FILE) ps -ylC java --sort:rss | grep $PID | awk '{ sum += $9 } END { print sum }'

...

# total_java_processes_count
env PID=$(cat PID_FILE) ps -ylC java --sort:rss | grep $PID | wc -l

To get the PID, you can use tools like jps -v 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment