Tomcat- How to check the memory settings currently in use
I have set up a Tomcat server using Server 2008 and IIS 7.
How can I tell if the JAVA_OPTS environment variable is actually being used?
I've heard before that the I have to edit the service.bat file in order to make the JAVA_OPTS environment variable be used, but how can I tell if it's successful?
I haven't been able to find out if there is a way to view this in the logs or something else more quantitative. The only way I could think of to try to test it is to edit the variable and try to tell if there is a difference in performance. I set the JAVA_OPTS to be the following:
-server -Xmx1k -Xms1k-Xmn1k -Xss128k -XX:+UseParallelGC -XX:ParallelGCThreads=20 -XX:PermSize=1k -XX:MaxPermSize=1k
Also, I found documentation saying to change the following line in service.bat from:
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" --JvmMs 128 --JvmMx 256
to:
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" %JAVA_OPTS%
I got no errors when I ran the command
service install ServiceName
So far everything seems to be running as fast as it always is before I reinstalled the service with the changed memory settings, making me think that the JAVA_OPTS isn't affecting anything.
Sorry if this is a broad sort of question, but I haven't found a good lead to go off of yet as to what is actually happening in the back end. Can somebody shed some light on this?
Alright, I found the information I was looking for so I'm going to accept my answer because I'm giving more details, but +1 to David Levesque for the leads.
I found out that the memory settings I was trying to set were not being used. In order to change the memory settings I used the tomcat7w in the \bin folder.
Run the following command:
tomcat7w //ES//<ServiceName>
Then the following should pop up:
Click the Java tab that is underlined and add the arguments in the highlighted areas.
In order to check this, I used the jinfo executable (in the \bin folder). Jinfo prints Java configuration information for a given Java process. Run this command using the following syntax:
jinfo -flags PID-of-Tomcat-executable
The following little script saved me some time from having to find out Tomcat's PID every time, so I figured I may as well post it here:
@echo off
for /f "tokens=1,2 delims= " %%i in ('=tasklist ^| findstr "tomcat"') do (
echo Tomcat Executable = %%i
echo Tomcat Process ID = %%j
set tomcat_pid=%%j
)
echo %tomcat_pid%
%JAVA_HOME%\bin\jinfo -flags %tomcat_pid%
You can use the jinfo
utility that comes with the JDK to query the VM flags and system properties at runtime.