Tomcat memory overflow, modify settings

Source: Internet
Author: User

Problem description:

1. java. Lang. outofmemoryerror: Java heap Space

JVM heap setting refers to the setting of memory space that JVM can allocate during Java program running. the JVM automatically sets the heap size value at startup. The initial space (-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-xmn-XMS-xmx provided by JVM to set the configuration. The heap size is the sum of young generation and tenured generaion.

2. java. Lang. outofmemoryerror: permgen Space

The full name of permgen space is permanent generation space, which refers to the permanent storage area of the memory. This memory is mainly used by JVM to store class and meta information, when a class is loaded, it will be placed in the permgen space. It is different from the heap region where the class instance is stored. GC (garbage collection) permgen space is not cleaned up during the main program running period. Therefore, if your application contains many classes, the permgen space error may occur, this error is common when the web server pre-compile the JSP. If your web app uses a large number of third-party jar files and the size exceeds the default JVM size (4 MB), this error message is generated.

Solution:

1. modify memory settings in Linux

(1) Open the tomcat/bin/Catalina. Sh File

(2) Find the line # java_opts = "$ java_opts-dorg. Apache. Catalina. Security. securitylistener. umask = 'umask '".

(3) Delete the previous #

(4) Add "-xms512m"-xmx1024m "-server-XX: permsize = 128 M-XX: maxpermsize = 256m to the end of $ java_opts.

2. modify memory settings in Windows

(1) Open the tomcat/bin/Catalina. BAT file

(2) locate set java_opts = % java_opts % logging_config %.

(3) Replace % java_opts % with "-xms512m" "-xmx1024m"-server-XX: permsize = 128 M-XX: maxpermsize = 256 m


"-Xms512m" "-xmx1024m" indicates the initial value and maximum value of Java heap space.-server-XX: permsize = 128 M-XX: maxpermsize = 256m is the initial value and maximum value of permgen space.

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.