Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Prior to the introduction of Java 2 Platform, Standard Edition (J2SE) 1.4.1, writing effective applications that needed high throughput or minimal pause time during execution proved difficult for Java developers. Now, version 1.4.1's three new garbage collection algorithms specifically target these types of applications. In this article, I introduce these algorithms in the broader context of Java application development. I discuss the advantages and disadvantages of the algorithms, and recommend when they should and should not be used.
Imagine you live in a really small town (let's call it JavaVille). It has one main street, and, for fun, residents cruise the street, throwing candy wrappers and old computer parts out their car windows. This creates quite a mess, and the town has hired a full-time garbage collector to deal with the problem.
Bear with me for a minute. This is a really useful metaphor.
Now, imagine you are the town garbage collector, or sanitation engineer. With your garbage truck, you pick up all the trash left on the street. However, your truck is so big that no other cars can travel on the main street while you're collecting garbage. This gives people something else to complain about—they can't do anything else while the garbage truck travels through town. You try to stay out of the way, but sometimes, certain vehicles must get through, like ambulances and fire trucks.
To alleviate the situation, the town council votes to add some new streets so people can go about their business even when the garbage truck is running. They also decide to buy more garbage trucks so garbage collection takes less time.
This is a really useful metaphor for thinking about Java garbage collection, where multiple application threads (litterbugs) create garbage, and one thread (you) cleans it up. The application threads and the garbage collector share a single CPU (the main street), and all activity in the applications must stop while garbage collection is in progress (stop the world). You can make garbage collection less noticeable by adding more CPUs (streets) or more garbage collection (GC) threads (garbage trucks). Note that adding more GC threads (trucks) won't do you any good unless you have enough CPUs (streets) for them to work effectively in parallel.
Garbage collection is a complex subject. Before I discuss the new garbage collection algorithms, we should look at the history of Java garbage collection and the situation as it existed before J2SE 1.4.1. This should make it easier to understand current garbage collection and the reasons behind the new algorithms.
When Java was originally developed, the JDK shipped with a mark-and-sweep garbage collector. A mark-and-sweep garbage collector proceeds in two phases:
Garbage objects are identified by traversing references from the current application stack frames; unreachable objects are assumed to be garbage.