Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Java General Java Eligibility for garbage collection Tutorial

An object is eligible for garbage collection when no live thread can access it. An object can become eligible for garbage collection in different ways.

Tutorial Details:

Java Eligibility for garbage collection

An object is eligible for garbage collection when no live thread can access it.

An object can become eligible for garbage collection in different ways:

If the reference variable that refers to the object is set to null, the object becomes eligible for garbage collection, provided that no other reference is referring to it.

If the reference variable that refers to the object is made to refer to some other object, the object becomes eligible for garbage collection, provided that
no other reference is referring to it.

Objects created locally in a method are eligible for garbage collection when the method returns, unless they are exported out of the method (that is, returned or thrown as an exception).

Objects that refer to each other can still be eligible for garbage collection if no live thread can access either of them.

The Integer object initially referred to by the reference o1 becomes eligible for garbage collection after line 3. This is because o1 now refers to the String object. Even though o2 is now made to refer to null, the String object is not eligible for garbage collection because o1 refers to it.


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Java General Java Eligibility for garbage collection Tutorial

View Tutorial:
Java General Java Eligibility for garbage collection Tutorial

Related Tutorials:

Accelerate your Java apps! - JavaWorld - September 1998
Accelerate your Java apps! - JavaWorld - September 1998
 
Build servlet-based enterprise Web applications - JavaWorld - December 1998
Build servlet-based enterprise Web applications - JavaWorld - December 1998
 
The Java HotSpot Performance Engine is set to break new records - JavaWorld
The Java HotSpot Performance Engine is set to break new records - JavaWorld
 
Java memory management
Java memory management
 
Clearing resources
Clearing resources
 
Smart object-management saves the day - JavaWorld November 1999
Smart object-management saves the day - JavaWorld November 1999
 
Cleaning up after Jini services - JavaWorld March 2000
Cleaning up after Jini services - JavaWorld March 2000
 
Activatable Jini services, Part 2: Patterns of use - JavaWorld October 2000
Activatable Jini services, Part 2: Patterns of use - JavaWorld October 2000
 
Pick up performance with generational garbage collection
Pick up performance with generational garbage collection
 
Java Tip 130: Do you know your data size?
Java Tip 130: Do you know your data size?
 
J2ME devices: Real-world performance
J2ME devices: Real-world performance
 
J2SE 1.4.1 boosts garbage collection
J2SE 1.4.1 boosts garbage collection
 
Garbage Collection in the Java HotSpot Virtual Machine
Garbage Collection in the Java HotSpot Virtual Machine Gain a better understanding of how garbage collection in the Java HotSpot VM works, and learn to take full advantage of it when designing, developing, and deploying your Java applications.
 
Servlet Essentials
This document explains the concepts of Java Servlets and provides a step-by-step tutorial for writing HTTP Servlets with complete source code for the example Servlets. The tutorial and the other chapters cover all facets of Servlet programming from a ...
 
JavaServer Pages Technology - Documentation
Sun's tutorial for Java Server Pages that provide a good introduction to design web pages with JSP.
 
Asking "Why" at Sun Laboratories: A Conversation with Director, Glenn Edens
Sun Laboratories Director, Glenn Edens, discusses new research developments in the Java language and the gratifications and trials of running a research lab.
 
Core Java Interview Questions!
Core Java Interview Questions! Core Java Interview Questions Question: What is transient variable? Answer: Transient variable can't be serialize. For example if a variable is declared as transient in a Serializable class and the class is written
 
Collection of Large Number of Java Interview Questions!
Collection of Large Number of Java Interview Questions! Collection of Large Number of Java Interview Questions The Core Java Interview Questions The Jakarta Struts Interview Questions
 
Collection of Large Number of Java Sample Programs and Tutorials
Collection of Large Number of Java Sample Programs and Tutorials Collection of Large Number of Java Sample Programs and Tutorials HelloWorld Java Program Simple Java Program for beginners that prints HelloWorld! on console.
 
Introduction to the JSP Java Server Pages
Introduction to the JSP Java Server Pages Welcome to JSP Section Introduction To JSP Java Server Pages or JSP for short is Sun's solution for developing dynamic web sites. JSP provide excellent server side scripting support for creating database
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.