Decrease Your Java IDE Lag by Fine-Tuning the JVM Garbage Collector
Join the DZone community and get the full member experience.Join For Free
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?
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
You can read more here.
Java (programming language) Java virtual machine Integrated development environment Garbage (computer science)
Opinions expressed by DZone contributors are their own.
Clear Details on Java Collection ‘Clear()’ API
MLOps: Definition, Importance, and Implementation
How To Use the Node Docker Official Image
Fun Is the Glue That Makes Everything Stick, Also the OCP