HotSpot garbage collectors decide to increase the total heap size immediately after completing the full GC, if the ratio of free space to the total heap size falls below a certain threshold. This ratio can be configured using one of the many -XX options for the garbage collector.
Looking at the memory graph, you will see that the heap size increases at the “saw points”; those. local highs. Each of them corresponds to a full GC. If you carefully look at the “points” where the heap expands, you will see that in each case the amount of free space immediately after the full GC is slightly higher than the previous such “point”.
I see that what happens is that the memory usage of the application is cyclical. If the GC is operating at or near the high point of the loop, it will not be able to free up as much memory as if the GC was operating at or near the low point. This variability may be sufficient to cause the GC to expand the heap.
(Another possibility is that your application has a slow memory leak.)
Does this mean that for an application with a long lead time, at some point it will exit the heap?
Not. Assuming that the memory usage of the application (i.e., the integral of the space occupied by accessible objects) is cyclic, the heap size will approach a fixed upper limit and will never exceed it. Of course, SOME are not inevitable.
Stephen c
source share