Go Linux Tomcat JVM Memory setup steps

Source: Internet
Author: User
Tags xms

Java.lang.OutOfMemoryError:PermGen Space

Java.lang.OutOfMemoryError:Java Heap Space

---------------------------------------------------------

Here, for example, the Tomcat environment, other Web servers, such as Jboss,weblogic, are the same reason.


One, Java.lang.OutOfMemoryError:PermGen space

The full name of PermGen space is permanent Generation space, which refers to the permanent storage area of memory,
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, the GC (garbage Collection) does not operate on the main program
PermGen space for cleanup, so if you have a lot of classes in your app, you're likely to have permgen space errors,
This error is common when the Web server pre-compile the JSP. If you use a large number of third-party jars under your web app, its size
The default size of the JVM (4M) is exceeded, and this error message is generated.
Workaround: Manually set the MaxPermSize size
Recommendation: Move the same third-party jar files to the Tomcat/shared/lib directory, which can reduce the memory consumption of the jar document.

Second, Java.lang.OutOfMemoryError:Java heap space
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 is started.
Its initial space (i.e.-XMS) is the 1/64 of physical memory, and the maximum space (-XMX) is the area of physical memory. You can use options such as the-XMN-XMS-XMX provided by the JVM to
To set. 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

----------------------------------------------------------

Modify JVM memory size under Linux:

To add the catalina.sh under Tomcat's bin, position cygwin=false before. Note the quotation marks to be taken, red for the newly added.

# OS specific support. $var _must_ is set to either true or false.
Java_opts= "-xms256m-xmx512m-xss1024k-xx:permsize=128m-xx:maxpermsize=256m"
Cygwin=false

Modify JVM memory size under windows:

Scenario One: Unzip the version of Tomcat to launch Tomcat via Startup.bat to load the configuration

To add the Catalina.bat under Tomcat's Bin

REM Guess catalina_home if not defined
The set current_dir=%cd% is added later, and the red ones are added for the new ones.

Set Java_opts=-xms256m-xmx512m-xx:permsize=128m-xx:maxnewsize=256m-xx:maxpermsize=256m-djava.awt.headless=true

Situation Two:

The Windows service performs bin\tomcat.exe. He reads the value in the registry instead of the Catalina.bat setting.

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

---------------------------------------------------------

The proportions of each parameter:

Xmx with PermSize and cannot exceed the total amount of memory that the JVM can obtain

PermSize must not be greater than xmx

Please refer to the other parameters in detail in the article, each parameter value size of this article is not discussed.

Go Linux Tomcat JVM Memory setup steps

Related Article

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.