Set your JVM to monitor how much time is spent doing garbage collection. You can do this by adding the -verbose:gc parameter to the JAVA_ARGS passed to the JVM when ATG starts up. The -verbose:gc option causes the JVM to output a message each time garbage collection is performed, including:

If you see your garbage collections happening too often or occupying a significant percentage of your CPU, you should either increase the Java heap size arguments or look for places in your application that are allocating memory unnecessarily.

If the garbage collection takes a very long time to complete, you may have configured your heap size to be too large for the amount of memory your system has. If your system is spending more than 20% of its CPU time on garbage collection, you have a significant performance problem that must be corrected. Use your OS monitoring tools to see if you are paging and check the process size of all of the processes running on your system. Compare this with the physical memory of your machine.

If your heap is very large, your garbage collections may occur very infrequently but may take a long time (30 seconds or more) to complete. This is a structural limitation of Java that is difficult to work around. When a full garbage collection occurs, it typically acquires the heap lock, which prevents all requests from being served during this time interval. You can potentially reduce the time of these garbage collections by forcing them to occur more frequently.

If your garbage collections take a significant percentage of your overall CPU time, you may have places in your code that allocate memory inefficiently. It is a good idea to reuse objects where possible, rather than creating them over and over again. You can use a memory profiler to determine where and how much memory is allocated by which places of the code. Only the allocation side of the garbage shows up in the stack traces and profiling. You have to factor in the time spent reclaiming garbage as well. You can also use the Performance Monitor to trace the memory allocation of various operations in your system. See Performance Monitor in the Monitoring Site Performance chapter.

loading table of contents...