12

I'm on ubuntu, and I need to confirm the heap size setting is being used by tomcat.

How can I do that?

I tried jmap but that doesn't seem to be on the server, can I download it individually somehow?

codecompleting
  • 9,251
  • 13
  • 61
  • 102

3 Answers3

11

Check the process parameters for -Xmx256m using ps command:

bahadir@dev1:/$ ps -ef | grep java
tomcat6    804     1 13 15:29 ?        00:00:23 /usr/lib/jvm/java-6-openjdk/bin/java 
-Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties 
-Djava.awt.headless=true -Xmx256m -XX:+UseConcMarkSweepGC 
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed 
-classpath /usr/share/tomcat6/bin/bootstrap.jar 
-Dcatalina.base=/var/lib/tomcat6 
-Dcatalina.home=/usr/share/tomcat6 
-Djava.io.tmpdir=/tmp/tomcat6-tmp org.apache.catalina.startup.Bootstrap start
Bahadır Yağan
  • 5,577
  • 3
  • 35
  • 39
7

You can do this with jmap, pretty easily.

$ jmap -heap [PID]

For example, first find the PID:

$ ps aux | grep tomcat
user123  61906 ... etc

Then attach to the process with jmap using the -heap option:

$ jmap -heap 61906

This prints the following, quite verbose output in which you should be able to spot whether your settings are being used:

Attaching to process ID 61907, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.80-b11

using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC
Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 25769803776 (24576.0MB)
   NewSize          = 6442450944 (6144.0MB)
   MaxNewSize       = 6442450944 (6144.0MB)
   OldSize          = 12884901888 (12288.0MB)
   NewRatio         = 2
   SurvivorRatio    = 4
   PermSize         = 21757952 (20.75MB)
   MaxPermSize      = 1073741824 (1024.0MB)
   G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 5368709120 (5120.0MB)
   used     = 2529188080 (2412.021713256836MB)
   free     = 2839521040 (2707.978286743164MB)
   47.10979908704758% used
Eden Space:
   capacity = 4294967296 (4096.0MB)
   used     = 2525489264 (2408.4942474365234MB)
   free     = 1769478032 (1687.5057525634766MB)
   58.80112908780575% used
From Space:
   capacity = 1073741824 (1024.0MB)
   used     = 3698816 (3.5274658203125MB)
   free     = 1070043008 (1020.4725341796875MB)
   0.3444790840148926% used
To Space:
   capacity = 1073741824 (1024.0MB)
   used     = 0 (0.0MB)
   free     = 1073741824 (1024.0MB)
   0.0% used
concurrent mark-sweep generation:
   capacity = 19327352832 (18432.0MB)
   used     = 10172808584 (9701.546272277832MB)
   free     = 9154544248 (8730.453727722168MB)
   52.63425711956289% used
Perm Generation:
   capacity = 195915776 (186.83984375MB)
   used     = 107975920 (102.97386169433594MB)
   free     = 87939856 (83.86598205566406MB)
   55.11343813374172% used
WattsInABox
  • 4,548
  • 2
  • 33
  • 43
6

Heap size used by tomcat (as any other java app) is determined by jvm -Xmx param.

So if your tomcat runs as a windows service, you would create environment variable CATALINA_OPTS=-Xms64m -Xmx256m.

Then, look at the file tomcat-install/bin/catalina.sh (.bat) and startup.sh (.bat), and check param JAVA_OPTS -Xmx1024m or something similar.

Good links: http://javahowto.blogspot.com/2006/06/6-common-errors-in-setting-java-heap.html http://www.coderanch.com/t/87422/Tomcat/increase-java-heap-size

Zorkus
  • 484
  • 1
  • 4
  • 13
  • thanks, but I want to confirm if tomcat picked up my settings. I think jmap can do that somehow. – codecompleting Dec 21 '11 at 21:05
  • Then you can connect to the running tomcat process using JVisualVM (tool from the jdk) and it will show you the jvm args tomcat was launched with. – Zorkus Dec 21 '11 at 22:01