Tomcat Memory Overflow

Source: Internet
Author: User
Tags xms

One, decompression version tomcat start Startup.bat1.java.lang.outofmemoryerror:java Heap Spac

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 setting the heap size
to modify the Tomcat_home/bin/catalina.bat, add the following line above the "echo" Using catalina_base: $CATALINA _base "":
Java Code
Set java_opts=%java_opts%-server-xms800m-xmx800m-xx:maxnewsize=256m
or modify catalina.sh
Add the following line to the "echo" Using catalina_base: $CATALINA _base "":
java_opts= "$JAVA _opts-server-xms800m-xmx800m-xx:maxnewsize=256m"

2.. 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 block of memory is mainly stored by the JVM class and meta information, class is loader will be placed in PermGen Space, unlike the heap area where the class instance (Instance) is stored, the GC (garbage Collection) does not clean up permgen space during the main program run time, so if you have a class in your application, PermGen space errors are most likely to occur 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 the MaxPermSize size
Modify Tomcat_home/bin/catalina.bat (Linux under Catalina.sh), in Java code
"echo" Using catalina_base: $CATALINA _base "" Add the following line above:
Set java_opts=%java_opts%-server-xx:permsize=128m-xx:maxpermsize=512m
under catalina.sh:
Java Code
java_opts= "$JAVA _opts-server-xx:permsize=128m-xx:maxpermsize=512m"

Decompression version of the Tomcat configuration java_opts you can see that you typically need to configure the Catalina file, but viewing the file shows that it reads the java_opts in the environment variable, so you can set it directly in the environment variable

second, the installation version of the Tomcat service started

to set the initial memory for Tomcat boot
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
to set
The following is a reference to the parameter settings for a Java JVM in a 1G memory environment:
java_opts= "-SERVER-XMS768M-XMX768M-XX:PERMSIZE=128M-XX:MAXPERMSIZE=256M-XX:
newsize=192m-xx:maxnewsize=384m "
Linux:
catalina.sh in the/usr/local/apache-tomcat-5.5.23/bin directory
added: java_opts= '-xms512m-xmx1024m '
the "M" description is MB, otherwise it is KB and will be reported out of memory when starting Tomcat.
-xms: Initial value
-xmx: Maximum value
-xmn: Minimum value
Windows:
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

III. Set TOMCAT memory in Eclipse

WINDOW->PREFERENCES->TOMCAT->JVM setting->add

 -xms768m-xmx768m-xx:permsize=128m-xx:maxpermsize=256m-xx:  newsize=192m-xx:maxnewsize=384m

java Run environment settings

window->preferences->java->installed JREs Select JDK to edit its JVM

Java projects and Web projects run in a different environment, the Java Project uses the JDK directly, and the Web project uses Tomcat, so there's no contradiction between configuring a duplicate configuration.

Tomcat Memory Overflow

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.