Profile Image
rizwan

Garbage collection frequently asked questions

I have few question related to GC if someone can answer. 

 

1. Is serial gc , parallel gc , g1gc and cms gc all generational garbage collectors?
2. Is permgem space part of xmx (heap value) or we need to define that seperately and is not part of heap memory
3. Is metaspace size deprecated in jdk8
4. Will Garbage collection in old generation cause stop the world event every time
5. Does minor gc means garbage collection which happens in eden space and survivor space? Is it always a stop the world event. Since it happens very frequently is it not a performance issue
6. Does Major GC means garbage collection in tenured space. Is it a stop the world event.
7. What does it mean by Full GC which written in the logs. Is it a minor gc or major gc. Is it also a stop the world event
8. Is Minor GC and Young GC same

  • gc

  • java

  • garbage

  • serialgc

  • parallelgc

  • g1gc

  • cmsgc

  • xmx

  • metaspace

  • jdk8

  • minorgc

  • edenspace

  • survivorspace

  • majorgc

  • fullgc

  • younggc

Profile Image

rizwan

Hi ram

Thanks for your feedback. Is it possible to connect with you. Need to enquire about professional services your team offers.

same email id we can connect

Please Sign In or to post your comment or answer

Profile Image

Ram Lakshmanan

Hello Rizwan!

 

 Good questions my friend. This might be useful for performance engineers who are going to take interview :-)
 
1. Is serial gc , parallel gc , g1gc and cms gc all generational garbage collectors?

 

Yes, that's correct. All of them are generational garbage collectors. In the algorithms that you have mentioned i.e. Serial GG, Parallel GC, Concurrent Mark and Sweep GC and G1 GC all have 2 JVM memory regions:

 

a. Young Generation (which contains eden and survivor generations)
b. Old Generation

 

Thus they are called as generations garbage collectors. Where as modern algorithms like Shenandoah and Z GC doesn't have Young and Old Generations. They are not considered as generational garbage collectors.

 

2. Is permgem space part of xmx (heap value) or we need to define that seperately and is not part of heap memory

 

Permgen is not part of JVM heap (i.e. -Xmx). They are outside of heap. It can be configured using '-XX:PermSize' and '-XX:MaxPermSize' JVM arguments.

 

3. Is metaspace size deprecated in jdk8

 

 No. Permgen is deprecated from JDK8 and not Metaspace. Permgen has been replaced by Metaspace from JDK 8. 
  
4. Will Garbage collection in old generation cause stop the world event every time
5. Does minor gc means garbage collection which happens in eden space and survivor space? Is it always a stop the world event. Since it happens very frequently is it not a performance issue
6. Does Major GC means garbage collection in tenured space. Is it a stop the world event.
7. What does it mean by Full GC which written in the logs. Is it a minor gc or major gc. Is it also a stop the world event
8. Is Minor GC and Young GC same

 Let me try to answer questions 4, 5, 6, 7, 8 together here. Because they are interconnected. 
 
 Broadly, GC events are classified in to two types:
 
 a. Minor GC (also known as young GC)
 b. Major GC (also known as full GC)
 
 Minor GC (also known as young GC) runs only young generation. It's widely spread misnomer that Minor GC doesn't stop the world. That's not true. Minor GC do pause the JVM. But since Minor GC operate only on young gc, which is comparatively much small region in most application, they pause for very small amount of time. But they do pause the JVM.
 
 Major GC (also known as full GC) runs on Young Generation, Old Generation and Metaspace. Since they run all 3 regions in most scenarios they tend to pause for a longer duration than Minor GC. 
 
 Here is a good introductory talk about GC tuning & troubleshooting, related the questions you have asked. You might find it useful.

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • gc

  • java

  • garbage

  • serialgc

  • parallelgc

  • g1gc

  • cmsgc

  • xmx

  • metaspace

  • jdk8

  • minorgc

  • edenspace

  • survivorspace

  • majorgc

  • fullgc

  • younggc