1

I have the following parameters in tomcat6.conf

JAVA_OPTS="-server -Xmx6144m -Xms3072m -XX:+UseConcMarkSweepGC -XX:MaxGCPauseMillis=999 -XX:ReservedCodeCacheSize=128m -XX:MaxPermSize=256m -Djava.awt.headless=true -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname= -Djava.rmi.server.useLocalHostname=false" 

but at peak time I see the following regularly,

ERROR memory-watcher - used 87.73865761212004%, max 6403194880 reaping at priority CRITICAL

is there any parameter I can use to to tune tomcat performance or GC ?

arashsami
  • 33
  • 1
  • 6

2 Answers2

0

The "-Xms3072m" and "-Xmx6144m" bits are where you're configuring your starting heap size and your max heap, respectively.

This is distinct from the "-XX:ReservedCodeCacheSize=128m" and "-XX:MaxPermSize=256m" bits, where you set up the generation memory (where the JVM stores classes, rather than the heap where it stores objects). One thing I notice here is that the sizes are different. Usually you want it to be the same for some cryptic reasons having to do with minimizing garbage collection.

You might also want to try "-XX:+UseParallelGC" instead of "-XX:+UseConcMarkSweepGC"...Usually if I have problems with one, then I have better luck with the other.

Satanicpuppy
  • 5,917
  • 1
  • 16
  • 18
  • Thanks for this, you know where you said "Usually you want it to be the same for some cryptic reasons having to do with minimizing garbage collection." Do you means the size of "-XX:ReservedCodeCacheSize=128m" and "-XX:MaxPermSize=256m" should be the same ? – arashsami Jul 11 '13 at 17:03
  • I think he means make your minimum and maximum heap sizes the same e.g. "-Xms6144m -Xmx6144m". – Friedrich 'Fred' Clausen Jul 12 '13 at 07:09
  • OMG NO! If someone tells you this a good idea, then they 1) they are probably wrong or 2) there are whole lot of qualifications of when this is a good idea which you've forgotten about – symcbean Dec 28 '17 at 14:22
  • Arguably, if setting max and min heap sizes identically avoids some kind of problem you should really fix that problem instead. – Spooler Feb 28 '18 at 23:40
0

GC is a function of the JVM (not specific to tomcat) and can be adjusted according to the docs for the particular flavor/version of java that you're using. IMO, most modern apps on modern java shouldn't need GC tuning provided that you're not doing something like starving the JVM for memory (87% is getting up there). In the example you provided, it might just be as easy as increasing the amount of memory available to the JVM. 6GB isn't a large amount of memory on modern day computing systems and you should really look at how much physical RAM is available for use on the system you're running this on. You can, in most cases, safely use half of the RAM or more for your JVM. Consider the recommended specs for your OS, and any other applications running on the box. Any memory left over after those requirements could and potentially should be made available to your JVM, lest you encounter memory bottlenecks. Especially so if the JVM you're working with is the main feature on a dedicated server.

-source: I was a sysadmin for a large organization with many app servers running on java, and I'm a java developer and user.

apocalysque
  • 399
  • 2
  • 8