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.
java -Dcom.sun.management.jmxremote -jar myservice.jar
- Connect via VisualVM and inspect CPU sampling
- Sort by method usage, identify hotspots
Console output:
Method | Time | Invocations loopProcessor() | 97.2% | 2,193,840
Lesson: Always watch for unbounded iterations, especially when processing user input.