Linux and Windows how tomcat modifies the memory size

  • 2020-11-20 06:12:34
  • OfStack

The initial space (-ES1en) is 1/64 of the physical memory, and the maximum space (-ES2en) is 1/4 of the physical memory.
This can be set using the -ES5en-ES6en-ES7en option provided by JVM

For example, the parameter setting reference of java jvm in 1G memory environment is given as follows:


JAVA_OPTS= " -server -Xms800m -Xmx800m -XX:PermSize=64M
-XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true  " 
JAVA_OPTS= " -server -Xms768m -Xmx768m -XX:PermSize=128m
-XX:MaxPermSize=256m -XX:NewSize=192m -XX:MaxNewSize=384m " 
CATALINA_OPTS= " -server -Xms768m -Xmx768m -XX:PermSize=128m
-XX:MaxPermSize=256m
-XX:NewSize=192m -XX:MaxNewSize=384m " 

Linux:

catalina.sh under /usr/local/ ES22en-ES23en-5.5.23 /bin
Add: JAVA_OPTS=' -Xms512m-Xmx1024ES33en '
Add "m" to indicate that it is MB, otherwise it will be KB. When tomcat is started, it will report out of memory.
-ES40en: Initial value
-ES42en: Maximum
-ES44en: Minimum

Windows
Join before catalina.bat


set JAVA_OPTS=-Xms128m -Xmx350m

If you start tomcat with ES54en.bat, the OK setting takes effect. 200M memory was allocated successfully.

But if instead of executing ES61en.bat to start tomcat, you start tomcat using windows's system services,
The above Settings will not work,
So set JAVA_OPTS= -Xms128ES72en-ES73en350ES74en doesn't work.
So if I allocate 200M up here, I'm going to allocate OOM
The windows service is performed by bin/ ES81en.exe. He reads the value in the registry, not the catalina.bat setting.
Solutions:


 Modify the registry HKEY_LOCAL_MACHINE/SOFTWARE/Apache Software Foundation
/Tomcat Service Manager/Tomcat5/Parameters/JavaOptions

The original cost for the


-Dcatalina.home= " C:/ApacheGroup/Tomcat 5.0 " 
-Djava.endorsed.dirs= " C:/ApacheGroup/Tomcat 5.0/common/endorsed " 
-Xrs

join

-Xms300m -Xmx350m

Restart the tomcat service and the Settings take effect
(For Tomcat 5.5, there is Procrun 2.0 Tomcat5/Parameters/Java under Apache Software Foundation
Set the values of JvmMs and JvmMx to change the decimal value.)

However, OS also has memory limitations

Ps: How do I get the maximum available memory for JVM

Test with the ES118en-ES119en-ES120en command at the command line, then gradually increase the value of XXXX to indicate that the specified memory size is available if it performs properly, otherwise an error message will be printed.

It turns out that JDK's maximum allowable memory values vary with the slightly different versions, so it's worth experimenting with 1 to see what the bottom memory can achieve in a practical application.

The point of this table is that if your machine has too much memory, you can only provide utilization by running a few more instances of it, such as Tomcat, you can install several more Tomcat and cluster it, and so on.

The result of this person's test, I quote 1 here

Corporate JVM version maximum memory (MB)client Maximum memory (MB)server


SUN 1.5.x 1492 1520
SUN 1.5.5(Linux) 2634 2660
SUN 1.4.2 1564 1564
SUN 1.4.2(Linux) 1900 1260
IBM 1.4.2(Linux) 2047 N/A
BEA JRockit 1.5 (U3) 1909 1902

So it has a lot to do with the system version of OS, jdk. If you want to make the most of memory, consider clustering.

1. In tomcat catalina. bat modify, join - Dcom. sun. management. jmxremote parameters


set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote

2. If es155EN5.0 is needed, open jconsole.exe in bin directory to connect and track the memory usage of tomcat


Related articles: