Identifying memory leaks | Option 1: Tune max heap size to optimize GC frequency


Identifying memory fragmentation


If there is a memory problem, but no reduction in free space after GC, check the charts for...

Allocation Failure means that an object needs heap space, but there is not enough contiguous space available in the JVM heap for it. Generally, Allocation Failure occurs when the JVM heap is used up. However, Allocation Failure also occurs if all the free space is fragmented, so that there is no contiguous space for this object. This problem is greatly magnified if there are large object allocations within the application because it becomes unlikely for the heap to have large contiguous space for these large objects. "Free Space before Allocation Failure" means the size of free space when Allocation Failure occurs. This space should be a small value because the heap size is nearly used up when Allocation Failure occurs. Therefore, the red line is always near the bottom of the chart. Figure 24-6 shows normal usage without fragmentation problems.

Severe fragmentation causes frequent GC cycles, and thus performance degradation. Rising GC frequency is another indicator of fragmentation.