Java.lang.OutOfMemoryError

Source: Internet
Author: User

One, Java.lang.OutOfMemoryError:PermGen space

1, PermGen space is the full name of permanent Generation space, refers to the memory of the permanent storage area.

Outofmemoryerror:permgen space from the surface is the memory benefits, the solution must also be increased memory.
Tell me why memory Benefits: This section 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 instance is stored, GC (garbage Collection) PermGen space will not be cleaned during the main program's run time, so if your app will load many classes, you will likely have permgen space errors. This error is common when the Web server pre-compile the JSP.
Correction Method:-xms256m-xmx256m-xx:maxnewsize=256m-xx:maxpermsize=256m
2.
A outofmemory error occurred while redeploy in Tomcat.

***************************************************
There are several possible reasons for this:
1, Proxool is used because the Proxool contains an older version of Cglib.
2, log4j, better not, just use common-logging.
3, the old version of Cglib, quickly update to the latest version.
4, update to the latest hibernate3.2
*****************************************************
3.

Here, for example, the Tomcat environment, other Web servers, such as Jboss,weblogic, are the same reason.

One, Java.lang.OutOfMemoryError:PermGen space 
-------------------------------------------------------- The full name of the-------------------
PermGen space is permanent Generation space, which is the permanent area of memory, and
This memory is primarily stored by the JVM with class and meta information. Class is placed in PermGen space when it is loader,
It differs from the heap area of the storage class instance (Instance), and the GC (garbage Collection) does not run on the main program for
PermGen Space for cleanup, so if you have a lot of classes in your app, you're likely to have permgen space errors, and
Such errors are common when the Web server pre-compile the JSP. If your web app uses a large number of third-party jars, whose size
exceeds the JVM's default size (4M), this error message will be generated.
Workaround: Manually set MaxPermSize size
Modify tomcat_home/bin/catalina.sh
in "echo" Using catalina_base: $CATALINA _base "" Add the following line:
java_opts= "-server-xx:permsize=64m-xx:maxpermsize=128m
Recommendation: To move the same third-party jar files to the Tomcat/shared/lib directory, This can be achieved by reducing the memory consumption of the jar document repeatedly.

Second, Java.lang.OutOfMemoryError:Java heap space
------------------------------------------------------------------------
Heap Size Setting
The JVM heap setting is the set of memory space that the JVM can provision during the run of the Java program. The JVM automatically sets the value of the heap size when it is started.
Its initial space (that is,-XMS) is 1/64 of the physical memory, and the maximum space (-XMX) is 1/4 of the physical memory.

You can use options such as the-XMN-XMS-XMX provided by the JVM to set it up. The size of Heap size is the sum of young Generation and tenured generaion.

************************************************************************************
Tip: This exception message is thrown in the JVM if 98% of the time is used for GC and the available heap size is less than 2%.
Tip: The Heap Size does not exceed 80% of the available physical memory, generally the-XMS and-XMX options are set to the same, and the-XMX value of-xmn is 1/4.
************************************************************************************

Workaround: Manually set the heap size

Modify Tomcat_home/bin/catalina.sh
Add the following line to the "echo" Using catalina_base: $CATALINA _base "":
Java_opts= "-server-xms800m-xmx800m-xx:maxnewsize=256m"
example, the following gives a reference to the parameter setting of the Java JVM in the 1G memory environment:
Java_opts= "-server-xms800m-xmx800m-xx:permsize=64m-xx:maxnewsize=256m-xx:maxpermsize=128m-djava.awt.headless= True "

Iii. Related Information
Digression: Often see netizens complaining about the performance of tomcat than ..., instability, in fact, according to the author years of experience, from the "Connected star" to the current real estate portal network, we use Tomcat as a Web server, daily visits million, Tomcat still running well. It is recommended that you have more questions from your own program, take a look at the doc documentation in Java and learn more about the JVM. The program developed in this way will be robust.

Java.lang.OutOfMemoryError

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.