Java JVM – Different Types of Heap in Java

heapjavajvm

I was faced with this question recently for the different types of heap memory available in Java.

I couldn't find much information online. Are there different types of heap memory available in Java ?

Best Answer

Heap is divided Young Generation, Old or Tenured Generation, and Permanent Generation.

The Young Generation is where all new objects are allocated and aged. When the young generation fills up, this causes a minor garbage collection. Minor collections can be optimized assuming a high object mortality rate. A young generation full of dead objects is collected very quickly. Some surviving objects are aged and eventually move to the old generation.

The Old Generation is used to store long surviving objects. Typically, a threshold is set for young generation object and when that age is met, the object gets moved to the old generation. Eventually, the old generation needs to be collected. This event is called a major garbage collection.

The Permanent generation contains metadata required by the JVM to describe the classes and methods used in the application. The permanent generation is populated by the JVM at runtime based on classes in use by the application. In addition, Java SE library classes and methods may be stored here.

enter image description here

Refer Oracle Java documentation for more details:

"Browse to JVM Generations"

Related Topic