This article here suggests to use -XX:+UseParNewGC ‘To enable a parallel young generation GC with the concurrent GC’.
My confusion is that in order to enable both parallel and concurrent GC, should I
- use
-XX:+UseParNewGCor - use both
-XX:+UseParNewGCand-XX:+UseConcMarkSweepGC?
PS
I am using JVM 6.
Since the document you linked was for a 1.4.2 VM that’s what I’ll assume you’re using (JVMs 5 and 6 behave differently).
From http://java.sun.com/docs/hotspot/gc1.4.2/
So the answer is you only need to use -XX:+UseConcMarkSweepGC and it will enable the concurrent collector with the parallel young generation collector.
Edit: for Java 6, the same flag (-XX:+UseConcMarkSweepGC) enables the concurrent collector. The choice of collector you want depends on a few things, and you should test different configurations. But there are some very general guidelines. If you have a single processor, single thread machine then you should use the serial collector (default for some configurations, can be enabled explicitly for with -XX:+UseSerialGC). For multiprocessor machines where your workload is basically CPU bound, use the parallel collector. This is enabled by default if you use the -server flag, or you can enable it explicitly with -XX:+UseParallelGC. If you’d rather keep the GC pauses shorter at the expense of using more total CPU time for GC, and you have more than one CPU, you can use the concurrent collector (-XX:+UseConcMarkSweepGC). Note that the concurrent collector tends to require more RAM allocated to the JVM than the serial or parallel collectors for a given workload because some memory fragmentation can occur.