Tomcat java. Lang. outofmemoryerror: permgen Space and Its Solution

Source: Internet
Author: User
Tags xms

Permgen space stands for permanent generation space, which refers to the permanent storage area of the memory outofmemoryerror: permgen space is actually out of memory, and the solution must be to increase the memory.
This part is used to store class and meta information. When the class is loaded, it is placed in the permgen space area, which is different from the heap area where the instance is stored, GC (garbage collection) does not clean up the permgen space during the main program running period. Therefore, if your app loads many classes, the permgen space error may occur. This error is common when the web server pre-compile the JSP.
Correction Method:-xms256m-xmx256m-XX: maxnewsize = 256 m-XX: maxpermsize = 256 m

The outofmemory error occurs during redeploy in Tomcat. There are several possible causes:
1. Use proxool because proxool contains an earlier version of cglib.
2, log4j, it is best not to use, only use common-logging
3. Update cglib of the old version to the latest version.
4. Update to the latest hibernate3.2. 3,

Take the Tomcat environment as an example. Other Web servers, such as JBoss and WebLogic, share the same principle.

I. java. lang. outofmemoryerror: The full name of permgen space is permanent generation space, which refers to the permanent storage area of the memory. This memory is mainly used by JVM to store class and meta information, when a class is loaded, it will be placed in the permgen space. It is different from the heap region where the class instance is stored. GC (garbage collection) permgen space is not cleaned up during the main program running period. Therefore, if your application contains many classes, the permgen space error may occur, this error is common when the web server pre-compile the JSP. If your web app uses a large number of third-party jar files and the size exceeds the default JVM size (4 MB), this error message is generated.

Solution: manually set maxpermsize to modify tomcat_home/bin/Catalina. sh Add the following lines to "Echo" using catalina_base: $ catalina_base ": java_opts ="-server-XX: permsize = 64 m-XX: maxpermsize = 128 m

Suggestion: Move the same third-party jar files to the tomcat/shared/lib directory to reduce the memory usage of jar files.

Ii. java. lang. outofmemoryerror: Java heap space heap size setting the JVM heap setting refers to the setting of the memory space that JVM can allocate during Java program running. the JVM automatically sets the heap size value at startup. The initial space (-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-xmn-XMS-xmx provided by JVM to set the configuration. The heap size is the sum of young generation and tenured generaion. Tip: if 98% is used for GC and the available heap size is less than 2% in JVM, this exception is thrown. Tip: the heap size should not exceed 80% of the available physical memory. Generally, you must set the-XMS and-xmx options to the same, and-xmn to the-xmx value of 1/4.

Solution: manually set heap size to modify tomcat_home/bin/Catalina. sh Add the following lines to "Echo" using catalina_base: $ catalina_base ": java_opts ="-server-xms800m-xmx800m-XX: maxnewsize = 256 m"

Iii. Example:
Java_opts = "-server-xms800m-xmx800m-XX: permsize = 64 m-XX: maxnewsize = 256 m-XX: maxpermsize = 128 M-djava. AWT. Headless = true"

Out-of-memory (outofmemory)-The application displays the "out-of-memory" error due to memory depletion in the Java heap or local memory.
Memory leakage-the continuous growth of Java heap or local memory will eventually lead to insufficient memory.
The technology for debugging Memory leakage status is the same as that for debugging memory insufficiency status.

Java heap-this is the JVM memory used to allocate Java objects.
If the JVM cannot obtain more memory in the Java heap to allocate more Java objects, a Java memory insufficiency (Java. Lang. outofmemoryerror) error will be thrown. By default, the application crashes.
Local Memory-this is the memory that JVM uses for its internal operations.
If the JVM cannot obtain more local memory, it will throw the local out-of-memory (local outofmemoryerror) error. This usually happens when the process reaches the operating system's process size limit, or when the computer has used up Ram and swap space.
Process size-the process size is the total memory occupied by the Java heap, local memory, and loaded executable files and libraries. On a 32-bit operating system, the virtual address space of a process can be up to 4 GB. From this 4 GB memory, the operating system kernel reserves a portion of memory for itself (typically 1-2 GB ). The remaining memory can be used for applications.

2.
A Java virtual machine is a software implementation that complies with relevant specifications and is stored in the memory. JVM is generated by the JRE (Java Runtime Environment) installed on the machine. Generally, a JVM is generated every time an application is run, but multiple programs can also be in the same JVM.

You can run the Java-x command to view non-standard program running options. The following three are my concerns:

-XMS set initial Java heap size
-Xmx set maximum Java heap size
-XSS set Java thread stack size

-Xmx sets the maximum number of memories that can be used by applications (not JVM). This value should not be too large to exceed the machine memory.
Example: Java-xmx50m testmemory
-XMS sets the memory stack size during program initialization. Sometimes it can be used to change the program running efficiency.
For example, run a program testmemory that occupies about 20 mb of memory in the following way:
Java-xms50m testmemory

Use this method to get the space used by the application.

/**//*
Returns the total amount of memory in the Java Virtual Machine. The value returned by this method may be vary over time, depending on the host environment.
*/
System. Out. println (runtime. getruntime (). totalmemory ());

3.
View the memory usage of the Java Process:
Windows Task Manager)

Increase the heap value of the running application.

// Command line execution Method
Java-xms256-xmx512m app

// Tomcat execution Method
In Windows, the file {tomcat_home}/bin/Catalina. bat

You can add the following settings at the beginning of the file:

Set java_opts =-xms256m-xmx512m

In UNIX, you can add the following settings before the file {tomcat_home}/bin/Catalina. sh:

Java_opts = '-xms256m-xmx512m'

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/gloomyboyo/archive/2009/12/02/4925505.aspx

Related Article

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.