r/javahelp • u/Historical_Ad4384 • Oct 24 '26
How to practise JVM thread profiling?
Hi
As the title states, I want to learn and practise profiling of JVM threads and its memory impact from garbage collection to identify bottlenecks.
I know this is a hard expectation to practise but my projects are not at a scale where we come across this problem to be solved.
Any advice on how I can simulate this requirement and get hands on practise on this topic?
16
Upvotes
View all comments
2
u/bogdanelcs Oct 26 '26
Make the problems yourself. Write small programs that misbehave on purpose: a hot
synchronizedblock with many threads, a static list that leaks, a loop that allocates huge numbers of short-lived objects, a deliberate deadlock.Run them with a tiny heap (
-Xmx64m) and GC logging (-Xlog:gc*), then profile with JDK Flight Recorder opened in JDK Mission Control, and usejstackthread dumps for the blocked threads.Putting load on a real app of yours with JMeter or Gatling while profiling is also good practice. Scott Oaks’s “Java Performance” is the book people usually point to.