How Does the Garbage Collector Work?

How Does the Garbage Collector Work?

We cant say surly when its work.We know that garbage collector uses a mark and sweep algorithm, When we are seeing about the java implementation its true but in the case of java specification we cant sure abut the java implementation.
We also know that garbage collector uses reference counting;The important concept is which we must to know that when does an object become eligible for garbage collection.Its ans is the thread.We cans say that every Java program has from one to many threads,Each thread has its own little execution stack. The garbage collector does some magical, unknown operations, and when it discovers an object that can\'t be reached by any live thread it will consider that object as eligible for deletion, and it might even delete it at some point.When we are discussing about reaching an object, we\'re really talking about having a reachable reference variable that refers to the object in question. If our Java program has a reference variable that refers to an object ,and that reference variable is available to a live thread, then that object is considered reachable.

By:umang
Date:2014-03-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related scjp1.5 chap8 Links

scjp1.5 chap8 interview questions and answers for experienced and fresher