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 2000
没有蜡笔的小新
没有蜡笔的小新 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:23

    If you are using Java 5 or later, you can connect to your application using jconsole to view all running threads. jstack also will do a stack dump. I think this should still work even inside a container like Tomcat.

    Both of these tools are included with JDK5 and later (I assume the process needs to be at least Java 5, though I could be wrong)

    Update: It's also worth noting that starting with JDK 1.6 update 7 there is now a bundled profiler called VisualVM which can be launched with 'jvisualvm'. It looks like it is a java.net project, so additional info may be available at that page. I haven't used this yet but it looks useful for more serious analysis.

    Hope that helps

提交回复
热议问题