Over a million developers have joined DZone.

Decrease Your Java IDE Lag by Fine-Tuning the JVM Garbage Collector

· Performance Zone

Download Forrester’s “Vendor Landscape, Application Performance Management” report that examines the evolving role of APM as a key driver of customer satisfaction and business success, brought to you in partnership with BMC.

Ever wondered why Eclipse/Netbeans keeps pausing for a while every now and then? Especially right when you want to show something in the code to your colleagues? It feels pretty embarrassing and awkward, doesn't it?

I found out that most of the time the IDE pauses because of Garbage Collector execution. This is a subtle little element in design of the JVM which usually does a great job in relieving us developers from worrying about memory consumption, and most people are just happy that it does its job well and ignore it most of the time. However, the consequences of running Garbage Collector may surprise us if we simply ignore it.

In short, when GC is running, it pauses execution of the application until it is done freeing the memory. This is for sure unacceptable for real-time systems, where Java is certainly not the number one option. But even in non-critical huge desktop applications, which modern Java IDEs certainly are, the GC may stop the whole application for several seconds. And this may happen several times during the day. You can imagine that with productivity tools like IDEs, this is simply dragging down the "productivity" effect.

A solution is to do some tweaking:
  • Increase memory for JVM on which the IDE is running (beware that this only reduces frequency of GC being called, but prolongs the execution time of a single GC run - it takes longer to collect garbage from a bigger pile...)
  • Switch default GC engine for a more concurrent engine, which tries to collect garbage continually even between stop-everything-until-done executions of complete GC
I recommend using the G1 or CMS Garbage Collector as alternatives to reduce the time that the application freezes.

You can read more here.

See Forrester’s Report, “Vendor Landscape, Application Performance Management” to identify the right vendor to help IT deliver better service at a lower cost, brought to you in partnership with BMC.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}