Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Has anyone found Garbage Collection tuning to be useful?

Tags:

I've read plenty of articles about tuning GC in Java and have often wondered how many people really use some of the more advanced features.

I've always avoided tuning where possible and concentrated on writing the simplest possible code I can (Brian Goetz's advice) - this seems to have worked well for me so far.

Are these tuning strategies resilient to change across VM versions or do they require constant re-assessment?

The one tuning that I have made use of is the -server flag.

like image 924
Fortyrunner Avatar asked Mar 08 '09 17:03

Fortyrunner


People also ask

What is garbage collector tuning?

What Is Garbage Collection Tuning. Garbage Collection GC tuning is the process of adjusting the startup parameters of your JVM-based application to match the desired results. Nothing more and nothing less. It can be as simple as adjusting the heap size – the -Xmx and -Xms parameters.

Why is garbage collection useful?

The garbage collector provides the following benefits: Frees developers from having to manually release memory. Allocates objects on the managed heap efficiently. Reclaims objects that are no longer being used, clears their memory, and keeps the memory available for future allocations.


1 Answers

Part of my current job is the care and feeding of a large java application that was designed to run with a large amount of memory (currently around 8 Gb), mostly due to ongoing calculations with lots of cached data. I did the initial deployment with the standard GC setup , mostly because there wasn't a simple way to simulate the production environment running at full tilt.

In stages, over the next few months, I've customized the GC settings. Generally, the biggest available knob seems to be adjusting the frequency and magnitude of incremental gc - the biggest improvement has been in trading off large periodic gc for smaller and more frequent ones. But we've definitely been able to see performance improvements.

I'm not going to post my specific settings because a) they're specific to our setup, and b) because I don't have them handy :). But in general, what I've found is

  • there's been a lot of work done in tuning the default gc settings. Almost always the defaults work better than any tweaks I would make.
  • At least for me, the situations where gc tuning was actually worthwhile were extreme enough that it was unreasonable to attempt to simulate them, so I had to do it experimentally and incrementally.

Here's a good reference from a prev. stackoverflow discussion.

like image 73
Steve B. Avatar answered Oct 02 '22 14:10

Steve B.