Page 3 of 5
Garbage collection can also be triggered if the heap's subregions are nearly full. In this case, the garbage collection thread's priority increases, thus increasing the chance that the garbage collection will run to completion. If the new generation is full, a minor collection is triggered; if the old generation is full, a major collection is triggered. The steps in a minor collection are:
A major collection uses the old generation garbage collector (mark-compact for J2SE 1.3) to reclaim old objects.
Some applications can't tolerate even the short pauses from incremental garbage collection. Examples include near real-time applications and applications that must service large transaction volumes. The new 1.4.1 algorithms were created to fill this gap.
The new algorithms are based on the observation that many machines used for low-pause or high-throughput applications have large amounts of memory and multiple processors. The algorithms are optimized to take advantage of the extra resources. Table 1 shows the new algorithms.
Table 1. The complete set of GC algorithms (* = new in 1.4.1)
|
The parallel (multithreaded) algorithms are optimized for machines with multiple CPUs. In J2SE 1.4.1, they are only used in the young generation. Using multiple threads allows garbage collection to proceed in parallel with the application thread, so the application can proceed without perceptible pauses. By default, the parallel collectors allocate one thread per processor. Note: If you have a single-processor machine, these algorithms will probably not help with application performance and could potentially diminish it.
The parallel scavenging collector is optimized for very large (gigabyte) heaps. It should provide very fast throughput with minimal pauses. It requires using mark-compact for the old generation.
The concurrent collector works with the old generation. It divides garbage collection into six phases:
The first (initial-mark) and fourth (remark) phases are stop-the-world techniques; the others can proceed in parallel with application threads. The multistep garbage collection allows the stop-the-world phase to be as short as possible, which means that application pauses for garbage collection should be minimized.
To select a particular garbage collection algorithm you will need to use a command-line switch. The switches are listed in Table 2:
Metaphor chosen was well-thought & helpful to understand...By Anonymous on April 29, 2009, 7:56 amMetaphor chosen was well-thought & helpful to understand. Thanks for this nice article. Ananth
Reply | Read entire comment
thanks so muchBy Anonymous on January 23, 2009, 4:02 pmthanks so much
Reply | Read entire comment
View all comments