Summary of Tomcat running Java Web memory overflow

Source: Internet
Author: User
If the program running in JVM is full of its memory heap and persistent storage region, and the program wants to create an object instance, the garbage collector will start, try to release enough memory to create this object. At this time, if the garbage collector is unable to release enough memory, it will throw an outofmemoryerror memory overflow error. Sun JVM memory management method: Sun's JVM is similar to the human family, that is, creating an object in a place gives it the chance to die multiple times before it occupies space for a long time, sun JVM is divided into: 1. the young generation, including Eden and two survivor spaces (the from space and the to space. old Generation (old generation) 3. the data partitions of permanent generation (permanent generation) Java virtual machines are generally classified as follows (not necessarily physical partitions): 1. heap: Mainly stores object instances and shares threads. STACK: stores the method call status of a specific thread, with the thread exclusive 3. local method Stack: stores the call status of local methods, with exclusive threads. PC register: Anyone who has learned the operating system course knows that the thread exclusive 5. method Area: Mainly stores the type information, and threads share. Therefore, when a memory overflow error is thrown, the type of Memory leakage is generally prompted, which is generally divided by region: 1. Heap Memory leakage Java. lang. outofmemoryerror: javaheap space: you are familiar with it. You can solve this problem by setting-xms2048m-xmx4096m. stack memory leakage: excessive information such as intermediate variables maintained during running of the current thread, for example, memory leakage in the stack over flow3. method zone (permanent heap) caused by a common endless loop, that is, Java. lang. outofmemoryerror: permgen space: the cause of the error is directly related to the type loading and unloading. You can solve this problem by setting-XX: maxnewsize = 256 m-XX: maxpermsize = m. Generally, when the server memory is too small and a large number of access services are provided, too many data objects may be cached, resulting in heap memory overflow. When the web application continues to expand, after the loaded lib Library reaches a certain size (4 MB), it is easy to report permgen Oom, that is, the method zone overflow. Write the parameter to the environment variable: Export catalina_opts = "-xms2048m-xmx4096m" Export java_opts = "-XX: maxnewsize = 256 m-XX: maxpermsize = 256 m "xmx cannot exceed 80% of the server's physical memory

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.