Which algirithm is being used by java runtime for garbage collection?

On what basis does java reclaim objects using Garbage Collection ?and explain the method i.e the step by step basis on how it is being done?
[154 byte] By [AJAVAYa] at [2007-10-2 22:14:10]
# 1

There are various whitepapers and the like on this.

As far as which objects may be collected, it's just any object that isn't referred to - directly or indirectly - by one of the root set of threads in the JVM.

Collecting algorithms vary from jvm to jvm. You'd do better to search the web for a whitepaper on the subject.

~Cheers

Adeodatusa at 2007-7-14 1:31:04 > top of Java-index,Java Essentials,Java Programming...
# 2

The basis is "mark and sweep". Follow all the live references from the active threads and their stacks marking the live objects, then clear all the unmarked space.

But it gets more complicated, with "generational" space management todeal specially with emphemeral objects and very long lived objects (most java objectsare one or the other.)

malcolmmca at 2007-7-14 1:31:04 > top of Java-index,Java Essentials,Java Programming...