Help the world stop coronavirus! Stay home!

Prev Next

Java / Garbage collection

Explain the structure of heap.

Heap is divided into different generation, for example, new (young) generation, old generation and PermGen space.PermGen space is used to store class metadata and over filling of PermGen space can cause java.lang.OutOfMemoryError:PermGen space.

Young Generation : It is place where lived for short period and divided into 2 spaces:

  • Eden Space : When object created using new keyword memory allocated on this space.
  • Survivor Space : This is the pool which contains objects which have survived after java garbage collection from Eden space.

Old Generation : This pool is basically contain tenured and virtual (reserved) space and will be holding those objects which survived after garbage collection from Young Generation.

  • Tenured Space: This memory pool contains objects which survived after multiple garbage collection means object which survived after garbage collection from Survivor space.

Permanent Generation : This memory pool as name also says contain permanent class metadata and descriptors information so PermGen space always reserved for classes and those that is tied to the classes for example static members.

In Java8, PermGen is replaced with Metaspace which is very similar. Main difference is that Metaspace re-sizes dynamically.

Code Cache (Virtual or reserved) : HotSpot Java VM includes code cache area that has memory which will be used for compilation and storage of native code.

❤Cash Back At Stores you Love !!!❤

Earn your $10 reward when you make your first purchase through Ebates by signing up with clicking below button.

Ebates Coupons and Cash Back

More Related questions...

What is the purpose of garbage collection in Java? How does Garbage Collection work in Java? Explain the structure of heap. Is garbage collection in Java automatic? When does an Object become eligible for Garbage collection in Java? How will you identify minor and major garbage collection in Java? Difference between system.gc() and runtime.gc(). How to identify if GC resulted due to calling System.gc()? What is finalize method in Java? How many times does the GC calls the finalize() method for an object? What does System.gc() and Runtime.gc() methods do ? If an object reference is set to null, will the GC immediately free the memory held by that object ? How do you trigger garbage collection through Java code? Does finalize method automatically chain like constructors? How to improve the possibility of JVM running of finalize method? Does Java support destructors? When to override finalize method in Java? What is the access modifier for finalize method? Best practice for calling super class finalize method. Can we call finalize method explicitly? What to avoid when overriding finalize method? What are the Garbage collection (GC) roots? Explain Stop-The-World (STW) pauses. What is JVM ergonomics? What is the default garbage collector on a server class Machine. What are the 2 JVM tuning parameters for parallel collector? What is the default garbage collector in Java? Explain Serial garbage collector. How to find which Garbage collector is running? Is objects with circular reference, object linked to each other, garbage collected? Explain JVM Escape Analysis.
Show more question and Answers...


Comments & Discussions