4

Just to clarify a point I seen here indirectly answered:

Is the best GC to use on multi-CPU / multi-Core machine, which mostly runs the application, is ConcurrentMarkSweeper (aka -XX:+UseConcMarkSweepGC)?

Also, there is something called G1, any idea when it will become available for Java6 ?

EDIT: I'm using Sun Java VM, 1.6.0_16-b01. I have real-time (as close to real-time as possible in Java) application, and naturally want GC sweeps to be as short as possible. There is plenty of CPU power (which ConcMarkSweep seems to require).

Thanks.

SyBer
  • 5,407
  • 13
  • 55
  • 64
  • 1
    g1 is in java 6 since u14 or something (but youhave to turn it on and it is a pre-release and not yet production quality). What is best typically depends on your application and its needs but I am sure you will get real answer explaining that (I am writing this with one hand while holding my day old kid with the other). – Fredrik Jan 11 '10 at 18:36
  • Please edit your question to indicate WHICH JVM you use. This is vendor dependent. – Thorbjørn Ravn Andersen Jan 11 '10 at 20:36
  • Fredrik, congratulations for the new-born! – SyBer Jan 11 '10 at 23:12

2 Answers2

8

It depends on what type of tolerance the application has for GC pauses. ConcurrentMarkSweep is best for reducing the size of the GC pauses and therefore latency while the Parellel GC will achieve the best throughput at the expense of longer GC pauses.

G1 is currently an experimental feature. I think it will not be generally available until Java7 is released.

I recommend you take a look at this page: http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html

It contains a lot of information about the GC algorithms and behaviour. There is a section with advice for selecting the best GC for your application: http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html#available_collectors.selecting

Aaron
  • 5,931
  • 4
  • 27
  • 31
  • Thanks for the link. So to summarize: * Maximum CPU utilization - Parallel GC (the default AFAIK) * Maximum responsiveness - ConcMarkSweep Correct? – SyBer Jan 11 '10 at 23:15
  • I think both are able to max your CPU utilization. Parallel will give you the maximum throughput (EG. Transactions per second). As you say ConcMarkSweep will give you maximum responsiveness. – Aaron Jan 12 '10 at 11:39
0

We use -server -Xss4096k -Xms12G -Xmx12G -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -verbose:gc -Xmaxf1 -XX:+UseCompressedOops -XX:+DisableExplicitGC -XX:+AggressiveOpts -XX:+ScavengeBeforeFullGC -XX:CMSFullGCsBeforeCompaction=10 -XX:CMSInitiatingOccupancyFraction=80 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:+CMSParallelRemarkEnabled -XX:GCTimeRatio=19 -XX:+UseAdaptiveSizePolicy -XX:MaxGCPauseMillis=500 -XX:+PrintGCTaskTimeStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintTenuringDistribution -Xloggc:gc.log

Works like a charm. See also What are the best garbage collection settings for client side?

Community
  • 1
  • 1
Martin
  • 1,385
  • 15
  • 21