2

I want to use a different garbage collector than the default Parallel GC for my web application when deployed on my production server, which will be on linux.

Say for an example i want to use Concurrent Mark Sweep GC for the application.

Now i have read that we can use this by adding -XX:+UseConcMarkSweepGC and various other JVM parameters to fine tune it.

So while packaging my war using maven i include this extra JVM parameters. example:

mvn clean package -Dgwt.extraJvmArgs="-Xms2048m -Xmx2048m -XX:PermSize=512M -XX:MaxPermSize=512M -XX:+UseConcMarkSweepGC" 

The war is packaged, i deploy it on my tomcat server which is running on linux environment.

Note i package this war on a windows machine then deploy the war in linux machine using putty and winscp

What i don't understand is how will this ensure that CMS GC is running? I mean shouldn't i include these changes where my application is running?

Or including these JVM parameters while packaging the was is good enough.

Same goes if i want to include various other JVM parameters, including while packaging the war is good to go or we need to include these some where else too?

Please explain.

Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105
Loui
  • 533
  • 17
  • 33

1 Answers1

3

Add these parameters in [TOMCAT_HOME]/bin/catalina.sh with JAVA_OPTS

JAVA_OPTS=-Dgwt.extraJvmArgs="-Xms2048m -Xmx2048m -XX:PermSize=512M -XX:MaxPermSize=512M -XX:+UseConcMarkSweepGC"

It doesn't have any effect on providing these while packaging the war file.

Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105
  • Giving this as JAVA_OPTS, but then tomcat not restarting or stopping or simply starting JAVA_OPTS="$JAVA_OPTS -Xms64m -Xmx1024m -XX:MaxPermSize=128m -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark" – Loui Jul 22 '15 at 09:18
  • @RahulLao That should go as seperate question. I pointed out the place to add those JVM flags. – Abimaran Kugathasan Jul 22 '15 at 09:24