Channels ▼

Gaston Hillar

Dr. Dobb's Bloggers

New Garbage Collectors Designed With Parallelism in Mind

May 22, 2009

On the one hand, Garbage Collectors simplify developers' lives, but on the other hand, they can become the greatest enemies of a parallelized algorithm's performance. Finally, Java 7 and .Net 4 are going to offer new Garbage Collectors really targeted for multicore microprocessors with large memories.I work with many programming languages. I work with unmanaged C++, C# and Java, among others. One of the most exciting features of both C# and Java is their Garbage Collectors. Most developers tend to forget about releasing unused resources. The recommendation is to leave the Garbage Collectors do their work. It is a "Mother Nature will provide" approach.

One of the great advantages of designing an algorithm that is going to be programmed using unmanaged C++ is that the developer is responsible of releasing the resources at the right-time. This is very important in complex algorithms running many concurrent tasks in multicore microprocessors. Parallelized algorithms usually require more memory than their serial code version. Choosing the right time to release the resources is crucial to achieve the best possible performance. There is no Garbage Collector marking elements to be released in the next collection process. You don't have to trust in the Garbage Collector's fortune-telling capabilities. You know the algorithm and you know exactly what you want to do. You control all the variables.

However, when you work with C# or Java and you trust in the Garbage Collectors' algorithms, your algorithm can be the next victim of their inaccuracies. As aforementioned, parallelized algorithms usually require more memory than their serial code version. Therefore, they add a great pressure to Garbage Collectors and they can add serious performance problems to algorithms with outstanding designs.

The great problem is that the algorithms used in the Garbage Collectors current versions were not optimized to run on microprocessors with a great number of cores. They were optimized for multiprocessor systems. However, a Core i7, for example, offers 8 logical cores in a single physical microprocessor. It is completely different than a system with 8 physical microprocessors. Garbage Collectors are really complex and the hardware available nowadays is different than the hardware that was available a few years ago.

Luckily, .Net 4.0 and Java 7 will offer new Garbage Collectors, really optimized for multicore microprocessors. They were both designed to target the new micro-architectures, support high levels of concurrency, manage larger memory and reduce the latencies introduced during applications' execution. Of course, they have many differences, because JVM (Java Virtual Machine) and .Net's CLR (Common Language Run-time) are very different. However, the Garbage Collectors are changing in similar directions.

This is great news for C# and Java developers thinking seriously about multicore programming.

.Net's new CLR 4 will offer a new Garbage Collector mode, Background GC, which reduces latency among other improvements. You can watch the video of the presentation offered by Joshua Goodman on Lang.Net Symposium 2009. CLR 4 is available in .Net Framework 4.0 Beta 1 and Visual Studio 2010 Beta 1.

Java 7 will offer the new G1, also known as Garbage-First, Garbage Collector. G1 is available as an early preview since Java 6 Update 14. You can read this excellent white-paper explaining its technical issues. Besides, you can go here and watch the slides of "The Garbage-First Garbage Collector", by Tony Printezis and Paul Ciciora.

Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 


Video