Solution for Tomcat Memory overflow

Source: Internet
Author: User
Tags memory usage

Problem performance:

The system prompts for an error when the user executes a large data application (the amount of the net byte code is about 5M):

Foreground error: HTTP Status 500-dispatch[eaitool] to method Listcurtree Retrun a exception

(Omitted below)

...............................................................

...............................................................

Background error: Java.lang.OutOfMemoryError:unable to create new native thread
At Java.lang.Thread.start (Native method)
At Org.apache.catalina.loader.WebappLoader.notifyContext (Webapploader.ja
va:847)

(Omitted below)

...............................................................

...............................................................

Problem Analysis:

Because of the problem caused by the Tomcat memory overflow, the main reason is that the JVM's virtual memory defaults to 128M, when the value is exceeded to release the previously occupied memory, and resulting in the image of TCP/IP packet loss, there are HTTP500 errors.
The solution is primarily to increase the amount of RAM available and to increase memory usage in the program.

Workaround:

How to: Increase Tomcat Memory:
In Tomcat's directory, which is in the front of the Tomcat41/bin/catalina.bat file, join
Set java_opts=-xms800m-xmx800m
The effect is that when you start Tomcat, the system memory will increase by nearly 800M use

Action method:
1, first turn off the Windows service in the TOMCAT4 service.
2, and then find the Tomcat/bin directory startup.bat, double-click to open it, you will find that the current Windows memory footprint will increase by nearly 800M.
3, the execution of the program, because it is Tomcat recompile program, so the first time will be relatively slow.

Conclusion:

After testing, we came to the following data:

When the system transmits about 2000 data, approximately 12M of NET data (uncompressed), the system-assisted running memory approximately occupies about 150M of space, that is, nearly 200M of memory footprint, and we expanded nearly 800M Java memory usage, this is enough for the business itself. So you don't have to worry about the transmission of big data.

Based on the Java Virtual machine principle, Java automatic garbage collection mechanism, that is, some memory for a long time not to use (nearly 2 minutes, depending on the use of frequency and priority, etc.), will automatically garbage collection, thereby freeing unused memory footprint.

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.