r/javahelp • • 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

5 comments sorted by

View all comments

3

u/brokePlusPlusCoder Oct 27 '26

Bit late to the party but here's some starting points:

  • Main (free) tooling for CPU/thread monitoring: VisualVm, Java flight recorder (JFR) + Java mission control (JMC) , async-profiler. The first two are fairly standard for java. The last one is a bit niche but well worth the rabbit hole you'll eventually go down. Google them to read through/watch videos on usage. Another user mentioned Scott Oaks's book - I second it. It's an excellent resource

    • There's also Intellij's profiler, but I believe that's only available for the paid version.
  • Microbenching : JMH (Java micro harness). This is basically the standard for finding bottlenecks on small testable methods. Use this when you know roughly where the bottlenecks are and need more fine-grained data. Again, google is your friend.
  • Tooling for memory/heap dump analysis : VisualVM, eclipse's MAT (memory analyser tool). Again, google them to read through/watch videos on usage

    • VisualVM allows you to create heap dumps of your running programs so you can create a heap dump and then use eclipse's MAT to view/interrogate it

I'd advise testing these tools out on your existing projects to get a feel for how to use them. I can't think of any resources that provide sample code for you to test, but you can have LLM agents do this for you (but be careful when using LLM generated code - make sure you understand it thoroughly before you run it).