How to check the size of tomcatjvm

How to modify and view tomcat memory size

In order to solve the problem of memory overflow when tomcat performs large concurrent requests, please modify the memory size of tomcat, which is divided into the following two ways:


1. Use tomcat running in command line mode such as catalina.bat

View the system's maximum supported memory command: java -Xmx1024m -version

1. Modify the tomcat\bin\Catalina.bat file
under Windows environment:

在166行左右
rem Execute Java with the applicable properties ”以下每行
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%

Add -Xms256m -Xmx512m after %DEBUG_OPTS%

Under linux environment:

Open the catalina.sh file in the bin file of the Tomcat installation directory and enter the editing state.
Add the following script after the comment:
JAVA_OPTS='-Xms512m -Xmx1024m'
JAVA_OPTS="$JAVA_OPTS -server -XX:PermSize=64M -XX :MaxPermSize=256m"

where JAVA_OPTS='-Xms512m -Xmx1024m' is to set the size of the memory used by Tomcat.

-XX:PermSize=64M -XX:MaxPermSize=256m Specify the memory size of the class space (for loading classes) 

After saving, run tomcat again in the command line mode, and then check whether the change has been successful through the method of how to observe the existing memory of tomcat introduced at the end.

 

 

 

Second, use the "service" in the system, or the tomcat run by the executable program of the start menu

1. Close the running tomcat


2.1 [Note]

[Higher version tomcat configuration method]

If it is a version of tomcat 5.5 or later than 5.0.28, in the Java tab, at the bottom, there will be three input boxes
Inital memory Pool:   
Maximum memory Pool:
Thread stack size:,
you can do the above operations here, To configure the memory size directly, you only need to set
the Inital memory Pool to 256 and the
Maximum memory Pool to 512

After clicking OK, restart tomcat to take effect

 

If you are a lower version of tomcat and find that the above input boxes are not available, please see the following steps

 

[Lower version tomcat configuration method]

在开始菜单中,找到“Apache Tomcat 5.0”,并选择“Configure Tomcat”,在弹出的对话框窗口中,切换到 Java VM 选项卡,并在 Java Options 输入框的最前面输入

-Xms256m -Xmx512m

即输入框中的内容会像下面的代码(与自己的环境有所区别)

-Xms256m -Xmx512m
-Dcatalina.home="C:\tomcat5"
-Djava.endorsed.dirs="C:\tomcat5\common\endorsed"
-Xrs

设置完后,点击“确定”,并重启tomcat即可。

 

三、查看现有tomcat的内存大小情况

1、启动tomcat
2、访问 http://localhost:8080/manager/status ,并输入您在安装tomcat时输入的用户与口令,如 admin ,密码 admin(密码是您在tomcat安装时输入的)

注:添加用户,修改conf/tomcat-users.xml

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>
  <user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>

3、进入了Server Status页面,可以在JVM表格中看到 
Free memory: 241.80 MB Total memory: 254.06 MB Max memory: 508.06 MB

上面的文字即代表了,当前空闲内存、当前总内存、最大可使用内存三个数据。
确定了最大内存足够大时,tomcat即可正常运转

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326957333&siteId=291194637