memory Overflow Tomcat memory configuration2012-05-04 19:23 70128 people read Comments (3) favorite reports Tomcatjavajvmspringgenerationhibernate
Setting the initial memory for Tomcat boot its initial space (that is,-XMS) is 1/64 of physical memory, and the maximum space (-XMX) is 1/4 of physical memory.
Can be set with options such as-XMN-XMS-XMX provided by the JVM
example, the following gives a reference to the parameter setting of the Java JVM in the 1G memory environment:
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:
In the/usr/local/apache-tomcat-5.5.23/bin directory, add the catalina.sh:
Java_opts= '-xms512m-xmx1024m ' to add "M" description is MB, otherwise it is KB, when starting Tomcat will be reported insufficient memory.
-XMS: Initial value-xmx: Maximum value-xmn: Minimum value
Windows
Add set java_opts=-xms128m-xmx350m at the front of the Catalina.bat
If the Tomcat,ok setting is in effect with Startup.bat startup. Enough to allocate 200M of memory successfully.
However, if you do not execute startup.bat to start Tomcat but use Windows system services to start the Tomcat service, the settings above do not take effect, meaning set java_opts=-xms128m-xmx350m It didn't work. Allocate 200M of memory above to Oom.
The Windows service performs bin\tomcat.exe. He reads the value in the registry instead of the Catalina.bat setting.
Workaround:
Modify the registry Hkey_local_machine\software\apache software Foundation\tomcat Service manager\tomcat5\parameters\javaoptions
The original value is-dcatalina.home= "C:\ApacheGroup\Tomcat 5.0"-djava.endorsed.dirs= "C:\ApacheGroup\Tomcat 5.0\common\endorsed"- XRS Join-xms300m-xmx350m
Restart Tomcat service, set to take effect
Solution to the JVM memory overflow problem with answer 2Tomcat: Tomcat's JVM memory overflow problem Resolution
Recently in the familiar with a project that has been developed for several years, the need to transfer the database from MySQL to Oracle, the first point of the JDBC connection to MySQL, packaged into Tomcat inside, can run, no problem, but when the JDBC connection point to Oracle, Tomcat on the continuous throw java.lang.OutOfMemoryError error, internet Google a bit, understand the operation of Tomcat, also solve the problem, share out, for reference.
1, the first is: Java.lang.OutOfMemoryError:Java heap space explanation: Heap Size setting The JVM heap setting is the set of memory space that the JVM can provision during the run of the Java program. The JVM automatically sets the value of the heap size when it starts, and its initial space (that is,-XMS) is 1/64 of the physical memory, and the maximum space (-XMX) is 1/4 of the physical memory. You can use options such as the-XMN-XMS-XMX provided by the JVM to set it up. The size of Heap size is the sum of young Generation and tenured generaion.
Tip: This exception message is thrown in the JVM if 98% of the time is used for GC and the available heap size is less than 2%.
Tip: The Heap Size does not exceed 80% of the available physical memory, generally the-XMS and-XMX options are set to the same, and the-XMX value of-xmn is 1/4.
Workaround: Manually set the heap size to modify Tomcat_home/bin/catalina.bat, add the following line on the "echo" Using catalina_base: $CATALINA _base "": Java Code set java_opts=%java_opts%-server-xms800m-xmx800m-xx:maxnewsize=256m Set java_opts=%java_opts%-server-xms800m-xmx800m -xx:maxnewsize=256m or modify catalina.sh in the "echo" Using catalina_base: $CATALINA _base "" Add the following line: java_opts= "$JAVA _opts- server-xms800m-xmx800m-xx:maxnewsize=256m "
2, followed by: Java.lang.OutOfMemoryError:PermGen space Reason: PermGen space is the full name of permanent Generation space, refers to the memory of the permanent storage area, This memory is primarily stored by the JVM with class and meta information, and class is placed in PermGen space when it is loader, unlike the heap area where the class instance (Instance) is stored, GC (garbage Collection) PermGen space will not be cleaned during the main program run time, so if you have a class in your application, you are likely to have PermGen space error, which is common when the Web server pre-compile the JSP. If you have a large number of third-party jars under your web app that are larger than the JVM's default size (4M), this error message will be generated.
Workaround: 1. Manually set MaxPermSize size modification Tomcat_home/bin/catalina.bat (Linux under Catalina.sh), in Java code "echo" Using Catalina_base: $CATALINA _ BASE "" Add the following line: Set java_opts=%java_opts%-server-xx:permsize=128m-xx:maxpermsize=512m "echo" Using catalina_base: $ Catalina_base "" Add the following line: Set java_opts=%java_opts%-server-xx:permsize=128m-xx:maxpermsize=512m catalina.sh: JAVA code java_opts= "$JAVA _opts-server-xx:permsize=128m-xx:maxpermsize=512m" java_opts= "$JAVA _opts-server-xx: Permsize=128m-xx:maxpermsize=512m "
In addition to see another post, feel very good, excerpt as follows:
Analysis Java.lang.OutOfMemoryError:PermGen Space found that many people attributed the problem to the SPRING,HIBERNATE,TOMCAT because they generated classes dynamically, causing the permanent heap overflow in the JVM. Then there are a few opinions about how to upgrade the Tomcat version to the newest or even simply without Tomcat. There are also doubts about the spring issue, which is hotly debated on the Spring Forum, as spring uses cblib in AOP to generate many classes dynamically. But the question is why the same problem arises from the open source of these trump cards, is it a more basic reason? Tomcat in Q&a very vague answer to this, we know this problem, but this problem is caused by a more basic problem. Then someone checked the more basic JVM and found the key to the problem. It turns out that the Sun's JVM has divided the memory into different areas, one of which is the Permenter area used to store very many classes and class descriptions. Sun was designed to think the area was fixed when the JVM started, but he didn't expect it to be used so extensively. And this area has a special garbage recovery mechanism, now the problem is that the dynamic loading class to this area, the GC has no way to recycle!
For the above two questions, my handling is:
The first line in Catalina.bat is incremented:
JAVA Code: Set java_opts=-xms64m-xmx256m-xx:permsize=128m-xx:maxnewsize=256m-xx:maxpermsize=256m
The first line in catalina.sh is incremented:
JAVA Code: java_opts=-xms64m-xmx256m-xx:permsize=128m-xx:maxnewsize=256m-xx:maxpermsize=256m
To modify the way Tomcat is in memory:
Modify Catalina.bat
In
Set java_opts=%java_opts%%logging_config%
This line is preceded by a
java_opts= '-xms512m-xmx1024m '
java_opts= "$JAVA _opts-server-xx:permsize=64m-xx:maxpermsize=256m"
where java_opts= '-xms512m-xmx1024m ' is the size of the memory used to set Tomcat.
The idea of expanding the JVM is too broad to be specified when running the JVM, if you are running Tomcat or changing catalina.bat if you are running eclipse, you are modifying Eclipse.ini So how the JVM's memory size changes is to see you run the specific program, there are different ways to change the program
Memory Overflow Tomcat memory configuration