Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what algorithm does a Garbage collector use?

 
ramanuja varun
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the garbage collector use any algorithm? If yes please do mention that.
 
Henry Wong
author
Marshal
Pie
Posts: 20894
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic