JVM Memory Overflow Tomcat configuration

Source: Internet
Author: User

There are two common types of JVM memory overflows:

The first type: Java.lang.OutOfMemoryError:PermGen space

Second type: Java.lang.OutOfMemoryError:Java heap Space

The first exception is due to the fact that there are too many files to load in our project, and the class files and jar files are loaded into the permanent zone of the JVM when the project is published, and thrown java.lang.OutOfMemoryError:PermGen when there is insufficient space in the persistence zone. Space

The second is a stack overflow, which causes the exception to be thrown when the project runs, and because the runtime produces too many object instances without being GC.

For the above two exceptions, and Tomcat usage, there are three types of solutions:

1, Tomcat decompression version through the Startup.bat script run:

When we run Tomcat through Startup.bat, we need Notepad catalina.bat and find

echo Using catalina_base: "%catalina_base%" the line,

Then add the above

Set java_opts=%java_opts%-server-xms100m-xmx1024m-xx:permsize=20m-xx:maxpermsize=100m

and set the parameter to a reasonable value.

2. Tomcat version registered as system service

The decompression version is registered as the system service mode, CMD enters the Tomcat/bin directory and executes the Service.bat install service name;

When you download the extract file without Service.bat please go to the official website to re-download, you may not encounter the problem, but I met!

At this point we can open the System Services management interface to see our registered successful Tomcat service

If the system service I registered is: tomcat9090, at this time we can shut down and start the Tomcat service, and can be set to boot;

If the service registration succeeds, it cannot be started, such as:

Or the error code is 1;

Check out the tomcat logs logs, see the logs in development, and log logs are critical.

There might be a reason why it could not be started:

2.1, is also a lot of online: Copy the MSVCR71.dll under the bin in the JDK to the bin in TOMCAT (no problem resolved)

2.2. Check if the JDK version is too low

2.3, see if the JDK and Tomcat are both 32-bit or 64-bit, when the difference between the two is through the Startup.bat script can be started, but when registered as a system service is unable to start, of course, the Tomcat installation version is the same, to use the same number of bits, and the version update time is similar;

2.4, when the Tomcat service can start, but stop during startup, check the logs log, at which time the maximum possible is PermGen space, the solution is

2.4.1:

Uninstall service: CMD enters Tomcat/bin directory and executes service.bat uninstall service name;

Then open Service.bat file to find

--jvmoptions "-dcatalina.home=%catalina_home%, .......... E%\conf\logging.properties "and add at the tail

The-xx:permsize=20m;-xx:maxpermsize=100m parameter is separated by ";"

such as: ".... conf\logging.properties;-xx:permsize=20m;-xx:maxpermsize=100m" parameter value according to the individual needs to set;

and set the following two parameters:

--jvmms 128 ^
--JVMMX 1024

Please re-register the system service after the above setup is completed.

2.4.2: Opening registry

Hkey_local_machine\software\apache Software Foundation\procrun 2.0\tomcat9090\parameters\java

Options Right click, modify, add-xx:permsize=20m;-xx:maxpermsize=100m

then restart the service;

3.Tomcat installation version, if there is no installation, or can not start problems, please refer to the 2.2 to 2.4 solution;

JVM Memory parameter Description Please refer to the official website:

Http://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html

Tired of it, go home to eat .....

JVM Memory Overflow Tomcat configuration

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.