1

My Server has only .5GB free memory out of 65GB.

             total       used       free     shared    buffers     cached
Mem:         64375      63788        587          0         70      11503
-/+ buffers/cache:      52213      12161
Swap:        67583       6923      60660

Tomcat is using around 22GB memory.

root     19915  2.9 36.4 42514364 24036804 ?   Sl   Jun21 433:25 /usr/jdk1.6.0_25/bin/java 
   -Djava.util.logging.config.file=/usr/local/apache-tomcat-7.0.11/conf/logging.properties 
   -server -Xms2048m -Xmx22528m -XX:MaxPermSize=2048m
   -XX:PermSize=512m -XX:MaxNewSize=512m -XX:NewSize=512m -Xnoclassgc
   -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 
   -Djava.endorsed.dirs=/usr/local/apache-tomcat-7.0.11/endorsed 
   -classpath /usr/local/apache-tomcat-7.0.11/bin/bootstrap.jar:
              /usr/local/apache-tomcat-7.0.11/bin/tomcat-juli.jar
   -Dcatalina.base=/usr/local/apache-tomcat-7.0.11 
   -Dcatalina.home=/usr/local/apache-tomcat-7.0.11 
   -Djava.io.tmpdir=/usr/local/apache-tomcat-7.0.11/temp 
   org.apache.catalina.startup.Bootstrap start

Other applications are using a small amount of memory. I don't understand what is happening. If there is a memory leak in tomcat then how to confirm it and fix that.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129
Al-Alamin
  • 111
  • 1
  • 3

2 Answers2

4

Stop staring at the column free: Linux ate your RAM for disk caching (cached 11503). As long as cached is high and swap used is low, you are not out of memory.

Tomcat have had issues with memory leaks - usually not from its own codebase but from poorly written applications. It's not necessarily the case here. Tomcat 7 has MemoryLeakProtection you can use to investigate this further:

Starting with tomcat 6.0.25, the manager webapp has a new "Find Leaks" button. When triggered, it displays a list of webapps (their context path) that have been stopped (this includes undeployed and redeployed ones) but whose classloader failed to be GCed.

If a leaking webapp is redeployed several times, it will appear as many times as it actually leaked.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129
4

Your Tomcat is using 22GB of memory because your -Xmx (JVM Heap Size) value is absolutely massive.

If possible, you should start by reducing this value to 2048, 4096 or 8192, depending on your application memory requirements and see what the sweet spot is.

Miuku
  • 760
  • 6
  • 7
  • Nicely spotted, @Miuku! I'll add some line breaks to the question for readability. – Esa Jokinen Jul 01 '18 at 09:06
  • 2
    Also, it's not necessarily wrong to use 22GB out of 64GB if the main use for this server is to run this application. If the memory needs to be more evenly distributed between applications, then decreasing `-Xmx` is the solution. – Esa Jokinen Jul 01 '18 at 09:12