aspose file tools*
The moose likes Java in General and the fly likes what algorithm does a Garbage collector use? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "what algorithm does a Garbage collector use? " Watch "what algorithm does a Garbage collector use? " New topic
Author

what algorithm does a Garbage collector use?

ramanuja varun
Ranch Hand

Joined: Aug 31, 2007
Posts: 47
Does the garbage collector use any algorithm? If yes please do mention that.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

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.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Welcome to JavaRanch!

According to Chapter 3 of The Java Virtual Machine Specification...
...the garbage-collection algorithm used ...[is] left to the discretion of the implementor.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: what algorithm does a Garbage collector use?