Some attempts to java.lang.OutOfMemoryError:PermGen space

Source: Internet
Author: User
Tags xms

Write Struts2 program Run when this problem occurs, now do the following two attempts, currently do not know whether it will continue to occur:

Try 1:

The full name of PermGen space is permanent Generation space, which refers to the permanent storage area of memory, which is used to store class and meta information, and class is placed in the PermGen space area when it is loaded. Unlike the heap area where the instance is stored, GC (garbage Collection) does not clean up permgen space during the main program run time, so if your app will load a lot of class, PermGen space error is likely to occur .

The reason for this problem is that the custom ClassLoader repeatedly loads the same jar many times, so as long as you avoid reloading the same jar again, you can solve the problem.

So the possible reasons are:
Too many classes are loaded
Too many jars are loaded
Too many jars loaded repeatedly

The specific solution:
1. Manually set the size of the MaxPermSize
Modify the Tomcat_home/bin/catalina.bat (Linux for catalina.sh) file,
Add this line to the echo "using Catalina_base: $CATALINA _base":

Set java_opts=%java_opts%-server-xx:permsize=128m-xx:maxpermsize=512m  
Catalina.sh modified as follows:
java_opts= "$JAVA _opts"-server-xx:permsize=128m-xx:maxsize=512m  

2. Modify the contents of the Tomcat_home/bin/catalina.bat file: Add after%_execjava%%java_opts%:
-xms=256m-xmx512m
Note that there are spaces before and after.

For example:%_execjava%%java_opts%-xms=256m-xmx512m (space), the following content is unchanged

3. Consider copying the same third-party jar files to the Tomcat/shared/lib directory, which can reduce the memory consumption of the jar files.

Mode 2:

Modify the MyEclipse as follows:
1. Window-->preferences...-->myeclipse-->application Servers-->tomcat,
2. Select the version of Tomcat you installed, select the following JDK, on the right
Optional Java VM arguments text box, enter:
-xmx256m-xms256m-xx:maxpermsize=256m

Now just record these two methods, specifically to verify.

Some attempts to java.lang.OutOfMemoryError: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.