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.
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 ...
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