views:

5592

answers:

4

This article here suggest to use -XX:+UseParNewGC 'To enable a parallel young generation GC with the concurrent GC'.

My confusion is that to enable both parallel and concurrent gc

  • do I just gotta use -XX:+UseParNewGC
  • or do i gotta use both -XX:+UseParNewGC and -XX:+UseConcMarkSweepGC

PS

i am using jvm 6

+5  A: 

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/

if -XX:+UseConcMarkSweepGC is used on the command line then the flag UseParNewGC is also set to true if it is not otherwise explicitly set on the command line

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.

sk
i still dont get it, so To enable a parallel young generation GC with the concurrent GC do i have to use both concmarksweepgc and parnewgc or just concmarksweepgc would do?
pdeva
Just -XX:+UseConcMarkSweepGC and I think the UseParNewGC flag has no effect (or might even cause an error) in Java 6.
sk
A: 

oops sorry i am using jvm 6. does that stand for jvm 6 too?

pdeva
+2  A: 

This blog entry has a nice breakdown of the different collectors, and which options are valid: http://blogs.sun.com/jonthecollector/entry/our_collectors

tpoindex