2

I'm trying to change the garbage collector on the server's JVM to combat a java.lang.OutOfMemoryError: GC overhead limit exceeded exception, as per some of the other questions I've found on here. Although I've ran into some confusion about the usage of these command line options. This is what I'm doing:

java -XX:+UseConcMarkSweepGC

However I'm getting the usage message, and no indication it has changed at all.

This is the output I'm seeing:

Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) where options include: ........

Is this the correct use of the command line arguments? Am I making a stupid mistake? (it happens a lot)

christopher
  • 26,815
  • 5
  • 55
  • 89

1 Answers1

2

Command line flags like that one are used by the JVM you create when running the java command, they're not "global" switches.

To use the flag, include it in the VM arguments of your normal execution.

Also, note that enabling ConcMarkSweepGC will not really help you, since all that it enables it potentially more proactive garbage collection. You either have:

Community
  • 1
  • 1
mikołak
  • 9,605
  • 1
  • 48
  • 70
  • Yeah dude, sorry but that means absolutely nothing to me. I've attached the argument into my start up script on the tomcat server. The problem is, I don't know *where* or *how* to use these commands. Could you explain a little more specifically? – christopher Sep 18 '13 at 11:26
  • 2
    @chris : I can, now that you've actually specified you're using Tomcat. [This thread](http://stackoverflow.com/questions/7738794/add-jvm-options-in-tomcat) describes how to use VM options in this case. That's where. As to **how**, that's a very large topic. I'll edit my answer to include some pointers. – mikołak Sep 18 '13 at 11:34