What exactly don't you understand about GC. You may want to search the Java in General forums and Google for that matter. There is tons of information out there. The Java tutorial at Sun's site is also very good.
Bosun (SCJP, SCWCD).
So much trouble in the world -- Bob Marley
balakrishnap Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however, your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy. Thanks again and we hope to see you around the ranch!!
Originally posted by balakrishnap: Pl explain about garbage collection
Java allows you to create as many objects as you want without worrying about destroying them. The JRE deletes these objects when it determines that they are no longer being used. This process is called as Garbage Collection.
There are tons of details about garbage collection but, as a quick overview, garbage collection is performed by a separate (daemon) thread which reclaims heap memory by removing objects that have been allocated and are no longer being used. An object is considered to be no longer used when there are no more references to it from an active part of the application. You can search in this forum or in the Java Programmer's Certification forum to find lots of information on garbage collection. Corey
Garbage Collector is a program that manages memory automatically wherein de-allocation of objects is handled by Java rather than the programmer. In the Java programming language, dynamic allocation of objects is achieved using the new operator. An object once created uses some memory and the memory remains allocated till there are references for the use of the object.
When there are no references to an object, it is assumed to be no longer needed, and the memory, occupied by the object can be reclaimed. There is no explicit need to destroy an object as Java handles the de-allocation automatically.
The technique that accomplishes this is known as Garbage Collection. Programs that do not de-allocate memory can eventually crash when there is no memory left in the system to allocate. These programs are said to have memory leaks.
Garbage collection in Java happens automatically during the lifetime of the program, eliminating the need to de-allocate memory and thereby avoiding memory leaks. In C language, it is the programmer’s responsibility to de-allocate memory allocated dynamically using free() function. This is where Java memory management leads.