开发者

High cpu usage for javaapplication

My java application's cpu usage is more(sometimes 80-100%). My application uses http data transfer in it.I checked cpu usage using jConsole. From that I realized that some thread pools use more time of cpu. I dont know how to find the threads in that pools. Somebody please help me to find the threads that cause 开发者_StackOverflowmore cpu usage..


Try to use VisualVM instead of JConsole to monitor your application. I'm not sure but VisualVM's thread analyzer should me more feature-rich.


One way is to use a fully-fledged profiler such as YourKit (you can download a free evaluation version from their Web site). It will tell you exactly which threads are taking up the CPU, and what exactly they're doing.


A profiling tool such as this should help you find hot spots in your application.

However, why do you think that using a lot of CPU is a bad thing? If there's work to be done then you want to get it done, so you'll use CPU. If you have a multi-threaded application, some threads doing processing others reading stuff from the network then high CPU usage may be exactly what should happen - for example if there's lots of analysis of the retrieved data.


Using the topthreads plugin in JConsole will quickly reveal what the busy threads are busy with... Start it with

jconsole -pluginpath topthreads.jar

You can download the topthreads jar file here: http://lsd.luminis.eu/new_version_topthreads_jconsole_plugin/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜