If you have a Java application that is consuming CPU when it isn't doing anything, how do you determine what it is doing?

后端 未结 8 1820
没有蜡笔的小新
没有蜡笔的小新 2021-01-01 19:44

I am calling a vendor\'s Java API, and on some servers it appears that the JVM goes into a low priority polling loop after logging into the API (CPU at 100% usage). The sam

8条回答
  •  时光说笑
    2021-01-01 20:39

    Facing the same problem I used YourKit profiler. It's loader doesn't activate unless you actually connect to it (though it does open a port to listen for connections). The profiler itself has a nice "get amount of time spent in each method" while working in it's less obtrusive mode.

    Another way is to detect CPU load (via JNI, so you'd need an external library for this) in a "watchdog" thread with highest priority and start logging all threads when the CPU is high enough for a long enough time. You might find this article enlightining.

提交回复
热议问题