performance / tuning tips. to the point.                
About Us | Site Map | Privacy
Disclaimer | Feedback
About RSS Feed
Add to My Yahoo!
Google Reader or Homepage
del.icio.us performancewiki.com Latest Items


© 2006-2007 PerformanceWiki.com
All Rights Reserved.







Troubleshooting Hanging Java Applications



If your Java applications (or JVM) show symptoms like 1) slower reponse times than usual, or 2) application seems to be hanging, or 3) on your 4-CPU multi-processor machine, 25% CPU usage on average, then chances are the JVM's garbage collector is becoming the scalability bottleneck of your application. The following sections explain the potential causes and help you tune JVM to lessen the problem, especially on SMP machines.

On a single-CPU machine, if the garbage collector of a JVM is running actively, 
your requests to the JVM will not get processed until, well, the garbage collection 
cycle finishes.  The task manager (on Windows) will show this:
The potential causes for frequent (and too frequent) garbage collection in a JVM 
are a) memory leaks in your Java application; and/or b) loading large files (such as 
large images, PDF, Word, Excel, etc) into JVM's heap for in-memory processing, therefore 
maxing out a pre-configured heap forcing garbage collection to kick off often.  
Remember, garbage collection happens when the free/total heap ratio goes under a 
certain value (default or admin-configured).

Because most garbage collection algorithms stop the world for some period of time, a 
single-threaded garbage collector can quickly become a scalability bottleneck, 
because all but one processor are idle while the garbage collector has suspended 
the user program threads.

JDK 1.4.1 and beyond offers at least six algorithms for garbage collecting to choose from, 
you're probably wondering which one to use. Figure below (copyright IBM developerWorks) 
offers some guidance, dividing collectors into single-threaded and concurrent, and into 
low-pause and high-throughput. Given what you know about your application and deployment 
environment, this may be enough to select the appropriate algorithm. For many applications, 
the default collectors work just fine -- so if you don't have a performance problem, 
there's no point in inviting more complexity. However, if your application is deployed 
on a multiprocessor system or uses a very large heap, you may get some performance boost 
from changing collector options.

To see the DW article, click here.