The Source for Java Technology Collaboration
User: Password:
Register | Login help    

Search

Online Books:
java.net on MarkMail:


Erase/Replace

Posted by editor on February 5, 2008 at 7:16 AM PST

Garbage collection gets even more clever

Garbage collection is one of those topics where the smart developer acknowledges how much he or she doesn't know about how it really works, while the know-it-alls dispense advice whose freshness date expired sometime around Java 1.3. Does garbage collection, by its very nature, always bring your VM to a complete halt? Should you use System.gc() to periodically clean things up manually? Or should you remain blissfully unaware of such concerns and create objects to your heart's content?

For those inclined to be too clever by half and manage their own memory (and hey, if you really like memory management, there's always C... but I digress), you might want to get up to speed on just how clever the JVM's garbage collector already is.

Jon Masamitsu describes the JVM's various garbage collectors in a recent blog, Our Collectors. He shows six collectors and describes their strategies and side effects, along with how to use or disable them by means of -XX flags:

  • "Serial" is a stop-the-world, copying collector which uses a single GC thread.
  • "ParNew" is a stop-the-world, copying collector which uses multiple GC threads. It differs from "Parallel Scavenge" in that it has enhancements that make it usable with CMS. For example, "ParNew" does the synchronization needed so that it can run during the concurrent phases of CMS.
  • "Parallel Scavenge" is a stop-the-world, copying collector which uses multiple GC threads.
  • "Serial Old" is a stop-the-world, mark-sweep-compact collector that uses a single GC thread.
  • "CMS" is a mostly concurrent, low-pause collector.
  • "Parallel Old" is a compacting collector that uses multiple GC threads.

He also describes a promising new collector in his diagram:

That box represents the new garbage collector that we're currently developing called Garbage First or G1 for short. G1 will provide:

  • More predictable GC pauses
  • Better GC ergonomics
  • Low pauses without fragmentation
  • Parallelism and concurrency in collections
  • Better heap utilization

G1 straddles the young generation - tenured generation boundary because it is a generational collector only in the logical sense. G1 divides the heap into regions and during a GC can collect a subset of the regions. It is logically generational because it dynamically selects a set of regions to act as a young generation which will then be collected at the next GC (as the young generation would be).

A lot of people understand garbage collection as simply the brute-force "stop the world" exercise that causes AWT apps from 10 years ago (on 10 year old hardware) to seize up, and thus give Java a bad name in some camps. But with a decade of optimization, GC has gotten more clever and more powerful and with some exceptions (which are probably the domain of real-time Java), is probably not something to attempt to second guess anymore.


Also in Java Today, a recent SDN Mobility Tech Tip looks at strategies for reliable, embedded monitoring systems, in Ultra-low Bandwidth Communication with Java ME. "In the U.S. Department of Defense as well as in commercial industries, there are several applications that need wireless communication at low data rates (and consequently with low power consumption). For instance, most modern vehicles now contain tire pressure monitoring systems. [...] In this tech tip, we're going to explore how to use Java ME and Sun SPOT technology to create a low-bandwidth wireless system to read sensor data."

Richard Hightower continues his introductory series to JSF in Getting started with JavaServer Faces 1.2, Part 2: JSF life cycle, conversion, validation, and phase listeners. "This sequel gives you a firm grasp of JSF's more-advanced features: custom validators, converters, and phase listeners. Along the way you'll gain an understanding of the JSF application life cycle."


Kirill Grouchnikov announces the Substance 4.2 official release in today's Weblogs. In it, he makes the "announcement of the 4.2 release for Substance look-and-feel project. The list of new features and a few screenshots inside."

Felipe Gaucho bridges the IDE gap in Netbeans & Eclipse - confluence is possible. "Java Projects can be developed on both IDEs without any modification. This blog entry shows how a good configuration can provide your developers a much more comfortable and productive environment than exposing them to exogenous tools."

Finally, John Ferguson Smart offers help with Unit testing your Spring-MVC applications. "A very short introduction to writing unit tests for your Spring-MVC applications."


In today's Forums, kbr explains an apparent bug in Re: Dialogue disappears when combo box dropped down. "I've looked into this bug and there are two separate issues. One is the disappearance of the dialog while the combo box is selected. While this does occur much more frequently with the new Java Plug-In, it is also reproducible with the old Java Plug-In. I found it occurred most frequently when another application's window mostly obscured the dialog, and then the focus was transferred back into the dialog by clicking on the combo box."

linuxhippy questions the desire for ahead-of-time compilation in Re: AOT compiler for Java update 10. "Really, this has been discussed up and down - internal SUN studies found out that AOT compilation does not help a lot when it comes to startup-time (keep in mind the compiled code has to be loaded from the _slow_ harddrive), furthermore performance of AOT-compiled code will be lower than hotspot-server compiled code and under some circumstances even slower than hotspot-client."

bddeveloper offers surprising guidance for would be Blu-Ray Disc Java developers in Re: [BD-J-DEV] New and Curious. "From a book point of view i would learn basic java syntax and that is about it from any modern book. But even then I am skeptical because of asserts and other new features in version 1.6 that are not support in 1.3 which is what BD-J uses. So I would try and find a 1.3 Syntax book because, not only is the API not back wards compatible but neither is the syntax. Then pick up a good book on AWT, NOT SWING.. I would actually recommend Amazon for this because you'll find a huge selection of old books"


Current and upcoming Java Events :

Registered users can submit event listings for the java.net Events Page using our events submission form. All submissions go through an editorial review before being posted to the site.


Archives and Subscriptions: This blog is delivered weekdays as the Java Today RSS feed. Also, once this page is no longer featured as the front page of java.net it will be archived along with other past issues in the java.net Archive.



Garbage collection gets even more clever
Comments
Comments are listed in date ascending order (oldest first)