Investigating Memory Results > Tuning Garbage Collection and Finding Over-allocations 

Tuning Garbage Collection and Finding Over-allocations

From the discussion in Understanding Loitering Objects” on page 88, it should be clear that your program’s runtime performance can be adversely affected by the garbage collector. In addition to eliminating loitering objects with Memory, and resolving performance bottlenecks in your code with Performance, you can assess the behavior of the garbage collector with your program.

Tuning garbage collections is dependent on the JVM that you are using to run your program. Although garbage collectors all perform the same basic function, the way they operate varies widely among JVMs and even within a JVM. JProbe can help with some general analysis, and some tasks that are common, but for complete tuning you will also need to consult your JVM vendor’s documentation.

A closely related issue is excessive object allocation. JVMs have many optimizations for allocating small, inexpensive objects, but objects that are expensive to allocate, even if they do not cause garbage collection problems, can hurt performance.

This section contains the following topics:

Understanding Garbage Collection Issues

Reducing Over-allocation of Objects

Examining Garbage Collection Data