Search code examples
javagarbage-collectionjvmdynamic-memory-allocation

What is meant by Full Garbage Collection in dynamic memory deallocation?


I am actually going through internals of different GC's those serves JVM i.e G1 , CMS , ParallelOld

just trying to understand:

What different action GC take when it perform full garbage collection?

Does it Forcefully deallocate memory?

What are situations in which its beneficial for applications?


Solution

  • The term "Full" is synonymous with "Major", as opposed to a "Minor" garbage collection cycle. These terms relate to generational garbage collection schemes, where a simple and fast algorithm is used to both allocate and deallocate new and short-lived objects, and a more complex one is used for old objects. The simple algorithm trades space for time because it requires two memory blocks of equal size, one of which is always empty. The algorithm for old objects makes the opposite tradeoff.

    Most of the time only Minor GC runs are performed, freeing enough memory to go on, and only occasionally a Major (Full) GC run is needed to recover space from the Old Generation. Since the full GC is a CPU-intensive, stop-the-world event, frequent full GCs are a problem for application performance.