Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Java General Java Behavior of the garbage collector Tutorial

A Java programmer does not have to worry about memory management, because it is automatically taken care of by the garbage collector. The Java virtual machine (JVM) decides when to run the garbage collector. The garbage collector is a low priority thread

Tutorial Details:

Java Behavior of the garbage collector

A Java programmer does not have to worry about memory management, because it is automatically taken care of by the garbage collector. The Java virtual machine (JVM) decides when to run the garbage collector. The garbage collector is a low priority thread that runs periodically, releasing memory used by objects that are not needed anymore.

The garbage collection (GC) algorithm varies from one JVM to another. There are different algorithms being used, like reference counting or the mark and sweep algorithm. See Resources for more information on garbage collection.

Running the garbage collector
The JVM usually runs the garbage collector when the level of available memory is low. However, the garbage collector cannot ensure that there will always be enough memory.

If there is not enough memory even after the garbage collector reclaims memory, the JVM throws an OutOfMemoryError exception. Note that the JVM will definitely run the garbage collector at least once before throwing this exception.

While you can request that the garbage collector run, it is important to note that you can never force this action.


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Java General Java Behavior of the garbage collector Tutorial

View Tutorial:
Java General Java Behavior of the garbage collector Tutorial

Related Tutorials:

Which Java VM scales best? - JavaWorld - August 1998
Which Java VM scales best? - JavaWorld - August 1998
 
Build servlet-based enterprise Web applications - JavaWorld - December 1998
Build servlet-based enterprise Web applications - JavaWorld - December 1998
 
Singletons vs. class (un)loading - JavaWorld - May 1998
Singletons vs. class (un)loading - JavaWorld - May 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
 
Java Tip 79: Interact with garbage collector to avoid memory leaks - JavaWorld
Java Tip 79: Interact with garbage collector to avoid memory leaks - JavaWorld
 
Cleaning up after Jini services - JavaWorld March 2000
Cleaning up after Jini services - JavaWorld March 2000
 
Use the JVM Profiler Interface for accurate timing - JavaWorld
Use the JVM Profiler Interface for accurate timing - JavaWorld
 
J2EE project dangers! - JavaWorld March 2001
J2EE project dangers! - JavaWorld March 2001
 
Diagnose common runtime problems with hprof
Diagnose common runtime problems with hprof
 
Java security evolution and concepts, Part 2
Java security evolution and concepts, Part 2
 
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?
 
J2SE 1.4.1 boosts garbage collection
J2SE 1.4.1 boosts garbage collection
 
Object equality
Object equality Writing equals and hashCode methods for data objects Summary In this article, Alex Blewitt describes the two most common methods in the Java language—equals() and hashCode()—and shows how they can be implemented correctly. The
 
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.
 
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
 
Site navigation
 

 

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

Copyright © 2006. All rights reserved.