The initial space (i.e. – XMS) is 1 / 64 of the physical memory, and the maximum space (- Xmx) is 1 / 4 of the physical memory.
It can be set by using the options provided by the JVM, such as – XMN – XMS – Xmx
For example, the parameter setting reference of Java JVM in 1G memory environment is given below:
-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
In the / usr / local / apache-tomcat-5.5.23/bin directory catalina.sh
Add: Java_ OPTS=’-Xms512m -Xmx1024m’
If you want to add “m”, it means MB, otherwise it will be KB. When starting tomcat, it will report that there is insufficient memory.
-XMS: initial value
stay catalina.bat Top entry
If you use startup.bat Start tomcat, OK settings take effect. Enough successful allocation of 200m memory
But if it’s not execution startup.bat Start tomcat, but use the system service of windows to start Tomcat service,
The above settings will not work,
That is to say, set Java_ Opts = – xms128m – xmx350m did not work
200m of memory is allocated above for oom
The windows service executes bin/ tomcat.exe . he reads the value in the registry instead of catalina.bat Settings for
terms of settlement:
/Tomcat Service Manager/Tomcat5/Parameters/JavaOptions
The original value is
Restart the Tomcat service and the settings take effect
(for Tomcat 5.5, there is a tomcat5 / parameters / Java of procrun 2.0 under Apache Software Foundation
Set the value of jvmms and jvmmx. Change the value of decimal system.)
However, the OS also has memory limitations
Attachment: how to get the maximum available memory of the JVM
In the command line, use the Java – xmxxxxm – version command to test, and then gradually increase the value of XXX. If the execution is normal, it means that the specified memory size is available. Otherwise, an error message will be printed.
It is found that the maximum allowable memory values of JDK with slight differences in versions are not the same. Therefore, in practical applications, we still need to test ourselves to see what kind of value the memory can achieve.
What I want to illustrate from this table is that if your machine has too much memory, you can only run a few more instances to provide the utilization of the machine. For example, if you run tomcat, you can install more Tomcat and cluster, and so on.
I’ll quote the results of other people’s tests here
Company JVM version maximum memory (megabytes) client maximum memory (megabytes) server
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 OS system version and JDK version. If you want to make the most of memory, consider using clusters.
1、 At Tomcat catalina.bat Add- Dcom.sun.management . jmxremote parameter
2、 You need to use jdk5.0 or above to open the jconsole.exe To connect and track the memory usage of Tomcat