How Garbage Collection (GC) works internally in detail in java - Best explanation ever

JVM follows mark and sweep algorithm for garbage collection.
Mark and sweep algorithm internal working in 3 steps >  
STEP 1 > Unreferenced objects (garbage) are not reclaimed immediately.
  • Instead, garbage(unreferenced objects) is gathered until memory is not full.
STEP 2 >When memory becomes full >
  • execution of the program is suspended temporarily,
  • mark and sweep algorithm collects all the garbage (i.e. all unreferenced objects are reclaimed )
STEP 3 >Once garbage is collected >
  • execution of the program is resumed.

Daemon threads are low priority threads which runs intermittently in background for doing garbage collection.

I’ll we soon updating this article for further garbage collection details.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
//start paginationJs //end paginationJs