If you've recently upgraded the RAM, or are moving your Tomcat applications to a larger box, you may want to update your allocated memory.
To find out how much RAM is allocated already to your Tomcat instance, if you have Tomcat installed as a Windows service, you can run Regedit and look at:
HKEY_LOCAL_MACHINE SOFTWARE Apache Software Foundation Procrun 2,0
Under that key will be all the tomcat service instances you have installed on that machine. If you expand an instance tree you will see another key named Parameters. Expand this and you will see a number of named values:
JvmMs - is the minimum memory, equivalent to -Xms JvmMx - is the maximum memory equivalent to -Xmx Options - any other java options you wish to set for this server.
When you run Tomcat as a service it calls the jvm.dll directly so anything you modify in one of the bat files will be disregarded. So you will need to set those options by changing those registry values. The default Tomcat configuration does not use any memory configuration. If you haven't set the -Xms or -Xmx parameters explicitly anywhere you will wind up with the JDK default which is 64M.
Be aware that even if you increase the physical memory size, if you are running 32 bit windows you won't be able to allocate over 2GB of memory per VM. On Win32 the max size for your heap is going to be 2 GB. While that is as big as it will be able to get on that platform, that does not necessarily mean that you will be able to allocate a 2GB heap. In order to achieve that, the JVM must be able to allocate that entire quantity in a set of contiguous addresses. Depending on what you have loaded, if there is anything loaded into memory that is not movable and interferes with allocating that block, it will fail to start and you'll have to reduce the size until it fits in what IS available.
There are a number of different ways to modify the memory settings for the JVM at Tomcat startup via the -Xmx and -Xms settings.
You can set these (and other JVM parameters) in either the JAVA_OPTS or the CATALINA_OPTS in the set_env.bat. These can also be set via the Windows System Environment dialogs. If that has been done you can type set JAVA_OPTS OR set CATALINA_OPTS at the command prompt, and if they are set you will see them. Or they can be set from the command line before starting Tomcat (although if that was being done it wouldn't help you in this case). These can also be set in any of the called startup scripts such as startup.bat, catalina.bat, or set_env.bat. Do a text search through all the bat files and check to see whether the environment variables are being explicitly set somewhere there.
Normally, the quickest way to find out what the actual startup setting is would be to edit catalina.bat.
Find the tag: doneSetArgs. Immediately after that add the line:
echo %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS%
When you next type startup it will print out the exact command line being used to start Tomcat. If you see an -Xmx parameter, the value immediately after that will be your maximum memory for that instance. If you don't see that setting at all, it is the JVM default, 64M.
Popular Links
Comments
Memory Allocation
What is the most amount of memory you could allocate to tomcat in a x64 OS?
And then secondly, what is the best way to allocate or set the values xmx, xms, permsize?
Chux
Post new comment