Common solutions for Java.lang.OutOfMemoryError in Java

Source: Internet
Author: User

In the development of many of us have encountered a memory overflow situation, in fact, memory overflow in several forms:

1. Java.lang.OutOfMemoryError:PermGen space exception Handling in Tomcat (most common)

Concept we can check, in fact, we are still concerned about the solution:

Workaround:

(1)

Manually set the MaxPermSize size modification tomcat_home/bin/catalina.sh

    echo "Using catalina_base:   $CATALINA _base"

Add the following line above:

     Java_opts= "-server-xx:permsize=64m-xx:maxpermsize=128m
(2) Modify the Tomcat configuration in eclipse:
Added:-xms256m-xmx1024m-xx:permsize=64m-xx:maxpermsize=128m

2. Java.lang.OutOfMemoryError:Java Heap Space

This problem occurs because there are too many objects created by the Java Virtual machine, and the virtual machine allocates enough memory space to the heap for garbage collection, which is related to heap space. There are two ways to solve this kind of problem:
1. Check the program to see if there are dead loops or unnecessarily repeatedly creating a large number of objects. After you find the cause, modify the program and algorithm.
2. Increase the size of the XMS (initial heap size) and XMX (maximum heap size) parameters in the Java Virtual machine. such as: Set java_opts=-xms256m-xmx1024m

Summary: Memory processing, is a developer of good development habits of the test, many years of development process, let me know, the development of great God Master is not more than cattle technology, is a good development habit of a form, details determine success or failure!

Common solutions for Java.lang.OutOfMemoryError in Java

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.