Developers' garbage collection dilemma

New tools try to improve memory management without slowing down the system, as traditional methods can


Garbage collection certainly doesn't sound like a particularly enticing subject, given that most associate it with dragging cans out to the sidewalk once a week. But garbage collection is an important a concept in software development, and it has offered critical memory management capabilities in platforms like Java and Microsoft's .Net. Yet the process can mean that applications pay a high price in terms of performance.

Attempts to address the issue through new tools have emerged recently from Azul Systems and Terracotta.

[ Is it time put the brakes on Java? InfoWorld columnist Neil McAllister explains why Java may have served its purpose. | Keep up to date on the latest in Java with the JavaWorld Enterprise Java newsletter. ]

The garbage collection challenge
In garbage collection, objects no longer used by a program are reclaimed, freeing up resources for the application and even the computer. But ironically, the act of garbage collection can tie up systems.

"Like many complex enterprise applications, we have a need to use large heaps for code in the JVM (Java Virtual Machine) cache. This often results in long garbage collection times. Severe 'stop the world' garbage collections can result in interruption of service," says Joey Caisse, CTO at News Digital Media.

"Java applications, especially in the enterprise sector [with many concurrent users, lots of data to be processed by the applications with low predictable latency], do suffer significantly from garbage collection," says Matthias Matook, CTO and architect at e-business service provider Ecetera.

The issues with garbage collection actually go back 30 years ago to programming languages like Lisp, says IDC analyst Al Hilwa. "The idea is to remove a cumbersome and error-prone process, namely memory management, from the hands of developers and automate it. When you automate something, you always are going to make trade-offs, but over time technology improves in such ways as to make these trade-offs only relevant in narrow circumstances."

How the new tools try to help
The Java runtime and the .Net framework offer automatic garbage collection technologies that help developers make fewer mistakes and overall write better code, Hilwa says. "These technologies have been critical in making custom software development mainstream in the enterprise. But for really demanding high-performance applications, the nature of garbage collection must be weighed carefully to ensure that nondeterministic pauses in application execution are not a problem."

Terracotta approaches the issue by bypassing Java garbage collection via its BigMemory product. Serving as an extended cache and a Java add-on to the company's Enterprise Ehcache product, BigMemory offers an in-process, off-heap cache for storing large amounts of data -- as much as 1TB. This improves memory utilization and application performance, the company says.

"Applications today are getting extremely large because of two things: One is the number of users they have to support, and two is the amount of data they have to support," says Terracotta CEO Amit Pandey. Web applications and their need to scale out have compounded the issue, he says. Although focused on Java today, Terracotta is working on similar technology for .Net.

Azul Systems tackles the garbage collection problem by offering an alternative Java runtime called Zing, which features an application-aware resource controller and allows memory heap sizes of as large as 1TB per instance. It offers 100 times greater throughput and memory allocation rates than other Java platforms, the company claims.

Zing runs on virtualized infrastructure and offers memory defragmentation advantages. "We can do [defragmentation] in parallel with the application" without having to stop the application, says Shyam Pillimarri, an Azul vice president.

The state of .Net and Java garbage collection
Microsoft's Doug Seven, group products manager of Visual Studio, notes that garbage collection has been used in .Net and Common Language Runtime since their inception: "The .Net framework's garbage collector manages the allocation and release of memory for your application. Each time you create a new object, the Common Language Runtime allocates memory for the object from the managed heap. As long as address space is available in the managed heap, the runtime continues to allocate space for new objects. However, memory is not infinite. Eventually the garbage collector must perform a collection in order to free some memory."

While Microsoft has optimized garbage collection with the goal of efficiency, users can run performance analysis tools to determine the effects of garbage collection, Seven says. He notes that .Net 4 features background garbage collection in which some parts of the process occur on a dedicated thread, thus improving performance.

Oracle declined to discuss Java garbage collection, but a developer of the JRuby programming language, which puts Ruby on the JVM, says that garbage collection technology has matured, so the performance issue has lessened. "The JVM's various garbage collectors have matured to a point where almost any size application can be accommodated," says Charles Nutter, a JRuby project architect at Rails hosting provider Engine Yard.

"What I run into far more often these days are allocation throughput bottlenecks where you simply can't allocate objects fast enough. They take almost no time [for garbage collection], but you can only allocate and initialize memory so fast," Nutter says. "All languages on the JVM suffer from garbage collection impact to a degree given the development of many short-lived objects, Nutter says. "Dynamic languages like JRuby often suffer a bit more, since we usually have to create objects to represent numbers and certain types of method calls too."

A correction was made to this article on Dec. 14, 2010.

This article, "Developers' garbage collection dilemma," was originally published at Follow the latest developments in business technology news and get a digest of the key stories each day in the InfoWorld Daily newsletter.

From CIO: 8 Free Online Courses to Grow Your Tech Skills
View Comments
Join the discussion
Be the first to comment on this article. Our Commenting Policies