Originally posted by ramanuja varun: Does the garbage collector use any algorithm? If yes please do mention that.
Wow. Yes. It uses tons of algorithms....
Overall, the Sun GC breaks the heap into two generations. Young, which is generally for newer short lived objects. And Tenure, which objects gets promoted to after this lived for awhile.
For the young generation, it supports two (or three) different GC algoritums -- which are all based on the copy garbage collector. For the old generation, it also supports three different GC -- which are based on the mark and sweep garbage collector. (although, I am not sure what algorithm the incremental gc is based on)
Then you have you RT JVMs, like BEA JRockit and IBM Metronome, which have GC that supports the realtime needs of the JVM.
Finally (and coolest of all), I work for a company that makes a hardware assisted JVM -- which has a GC that is pauseless.