Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You ask two questions:</p> <p><b>What does it mean to change garbage collectors in Java for better performance?</b></p> <p>This is a huge topic, and like some of the other responders, I urge you to do some reading. I recommend <a href="http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html" rel="noreferrer">Java SE 6 HotSpot[tm] Virtual Machine Garbage Collection Tuning</a> from Sun. The information below mostly comes from there. The "turbo-charging" java article recommended in another answer is older.</p> <p>In brief, one of the many options we have when running the JVM is to select a garbage collector, of which there are presently three:</p> <ul> <li>The serial collector (selected with the -XX:+UseSerialGC option) - this uses a single thread to do all collection work, and everything waits while it happens.</li> <li>The parallel collector (selected with the -XX:+UseParallelGC option) - this does minor collections (of the young generation) in parallel, but everything waits during the major collections.</li> <li>The concurrent collector (selected with the -XX:+UseConcMarkSweepGC option) - this allows most collection operations to happen while the application is running.</li> </ul> <p><b>What makes one garbage collector better than another?</b></p> <p>Your application does. Each of the garbage collectors has a "sweet spot" - a range of application profiles for which it is the superior collector.</p> <p>First, know that the VM is pretty good at selecting a collector for you, and as with most optimizations, you should not consider second-guessing it until you've identified that your application is not performing well, and that garbage collection is the likely culprit.</p> <p>In that case, you have to ask these questions: 1) is your app running on a single-processor machine, or multi? 2) Are you more concerned with "minimizing pause time", or with "maximizing throughput"? That is, if you had to choose between the application never pausing but getting less work done overall, versus getting more work done overall, but pausing from time to time, which would you pick?</p> <p>Roughly speaking, as a starting point:</p> <ul> <li>On a <b>Multi</b>-processor machine, mostly concerned with <b>minimizing pause time</b>, you'd tend to use the <b>Concurrent</b> collector (consider enabling incremental mode)</li> <li>On a <b>Multi</b>-processor machine, mostly concerned with <b>maximizing throughput</b>, you'd tend to use the <b>Parallel</b> collector (consider enabling parallel compaction)</li> <li>On a <b>Single</b>-processor machine, with <b>small datasets</b> (up to roughly 100Mb), you'd tend to use the <b>Serial</b> collector</li> <li>On a <b>Single</b>-processor machine, mostly concerned with <b>maximizing throughput</b>, you'd tend to use the <b>Serial</b> collector</li> <li>On a <b>Single</b>-processor machine, mostly concerned with <b>minimizing pause time</b>, you'd tend to use the <b>Concurrent</b> collector (consider enabling incremental mode)</li> </ul> <p>Again, though, the VM does a pretty good job of selecting a collector for you, and you're better off not overriding that unless and until you discover that it's not working well enough for your application.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload