Garbage Collection in the HotSpot JVM
Pop quiz: which is faster, Java or C++? If you are talking about allocation performance, the answer is Java, hands-down.
The performance of the garbage collector in the HotSpot JVM has improved steadily since JDK 1.0. The early garbage collectors were criticized for poor performance, but, except for some edge cases, garbage collection performance in HotSpot is now so good that allocation is an area where Java programs handily outperform comparable C++ programs.
The early JVMs used a simple mark-sweep collector, which was easy to implement and worked well enough for short-lived, small-heap applications. Current JVMs use a generational garbage collection approach, using different collection strategies for different areas of the heap, which for typical applications, offers excellent throughput and short pauses. Additionally, HotSpot versions 1.4.1 and later offer several alternate collectors for multiprocessor and large-heap systems.
In this session, we’ll explore the basic approaches to garbage collection, garbage collection options in the the HotSpot JVM, some common garbage collector tuning options, and some idioms to avoid in order to make your application coexist peacefully with the garbage collector.
About Brian Goetz
Brian Goetz has been a professional software developer for 20 years. He is the author of over 75 articles on software development, and his book, Java Concurrency In Practice, was published in May 2006 by Addison-Wesley. He serves on the JCP Expert Groups for JSRs 166 (concurrency utilities), 107 (caching), and 305 (annotations for safety analysis). He is a frequent presenter at JavaOne, OOPSLA, JavaPolis, SDWest, and the No Fluff Just Stuff Software Symposium Tour. Brian is a Sr. Staff Engineer at Sun Microsystems.
More About Brian »