Post

Profiling Spring Boot Applications with VisualVM

I was debugging a high CPU usage issue in one of our Spring Boot services. Turned out to be an accidental infinite loop triggered by malformed input.

To catch it, I used VisualVM:

  1. Start your Spring Boot app with remote debug flags:
1
2
java -Dcom.sun.management.jmxremote -jar myservice.jar

  1. Connect via VisualVM and inspect CPU sampling
  2. Sort by method usage, identify hotspots

Console output:

1
2
3
Method           | Time   | Invocations
loopProcessor()  | 97.2%  | 2,193,840

Lesson: Always watch for unbounded iterations, especially when processing user input.

This post is licensed under CC BY 4.0 by the author.