CPU usage of my Java application
Dear everyone,
I have a Java application that runs as a server - serving data to client apps.
So, the server app is designed to run infinitely, unless stopped.
The problem is that nearly after two weeks of operation, the server app starts
consuming large amounts of CPU progressively.
In windows task manager my server shows has these data:
ServerApp1032(PID)50(CPU)83:13:49(CPU Time)30,448(Mem usage)
The alarming part is that the value for CPU time keeps ticking up - 1 for
every second. This up ticking starts only after nearly two weeks of operation,
though.
Could you please help me in understanding the problem? Why is the CPU Time
up ticking? What is the significance of CPU Time, and what are the likely
culprits?
Thanks a lot!
George
You didn't say what eventually happens to your app - does it die, or becomes too slow, or what? That is, is there any real reason to worry? Part of the reason to ask about this is that Microsoft's software in infamous for its glitches. So who knows, maybe it's some problem with the Task Manager, rather than your software - say some counter in TM just overflows in 2 weeks :-)
If you really observe some problem with your app, you probably need some ligtweight monitoring tool for Java to get a better idea of what's happening. A tool that at least shows you the heap total/used size, the number of threads, the GC pauses length etc. could help. Actually, one very likely problem that you might have is that your app has reached some threshold wrt. memory usage, which forced GC to happen more frequently, hence the increased CPU usage. I know one tool, http://research.sun.com/projects/jfluid, which has these monitors - but the downside is that it needs its own customized JVM, which may be not the best thing to use for a production application. No doubt similar tools should exist that use a standard JVM. And at least for the heap consumption, you can easily get some data by just running your JVM with the -verbose:gc option.