Linux jetty Java.lang.OutOfMemoryError:PermGen Space and Jetty memory configuration tuning Solution

Source: Internet
Author: User
Tags xms

Jetty report Java.lang.OutOfMemoryError:PermGen Space and Jetty memory configuration tuning solution under Linux
Problem
Linux jetty under the release of the program and then start the jetty service, found that the boot is not, from the log to find the newspaper Java.lang.OutOfMemoryError:PermGen space.


Cause analysis
PermGen space, the full name is permanent Generation space, refers to the memory 3 zone in the permanent area. When the Java middleware starts, the associated jar package and. Class are loaded into the permanent zone, and the space used for the area is fixed, although it can be set. The reason for reporting this error is that the permanent zone overflows when you start loading. class.


Solution:
To modify the startup script for jetty:/etc/init.d/jetty
Java_options= "-xmx256m-djava.awt.headless=true-djava.library.path=/usr/lib"
Instead: (You can arrange your own memory properly)
Java_options= "-xmx1024m-xx:maxpermsize=1024m-djava.awt.headless=true-djava.library.path=/usr/lib"

------------------------------------------------------------------------
1. Meaning of the parameter
-vmargs-xms128m-xmx512m-xx:permsize=64m-xx:maxpermsize=128m
The-vmargs description is followed by the parameters of the VM, so the following are actually the parameters of the JVM
-xms128m JVM Initial allocation of heap memory
-XMX512M JVM Maximum allowable allocated heap memory, on demand
-xx:permsize=64m JVM Initial allocation of non-heap memory
-xx:maxpermsize=128m JVM Maximum allowable allocated non-heap memory, on demand

2. Heap memory allocation
The initial allocated heap memory of the JVM is specified by-XMS, and the default is the maximum allocated heap memory for 1/64;JVM of physical memory specified by-XMX, which defaults to 1/4 of the physical memory. When the default free heap memory is less than 40%, the JVM will increase the heap until the maximum limit of-xmx;
When free heap memory is greater than 70%, the JVM will reduce the heap until the minimum limit of-XMS. So the server generally sets-xms,-xmx equal to avoid resizing the heap after each GC.
Note: If-XMX is not specified or is small, the application may cause a java.lang.OutOfMemory error, which is from the JVM, not throwable, and cannot be captured with Try...catch.

3. Non-heap memory allocation
The JVM uses-xx:permsize to set the non-heap memory initial value, which defaults to 1/64 of the physical memory, and the maximum non-heap memory by Xx:maxpermsize, which by default is 1/4 of physical memory.

4.JVM memory Limit (max)
First, the JVM memory is limited to the actual maximum physical memory, assuming that the physical memory is infinitely large, the maximum value of the JVM memory is very much related to the operating system. In short, the 32-bit processor, although the controllable memory space has 4GB, but the specific operating system will give a limit,
This limit is generally 2GB-3GB (typically under Windows systems for the 1.5g-2g,linux system 2g-3g), and processors over 64bit are not limited.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Linux jetty Java.lang.OutOfMemoryError:PermGen Space and Jetty memory configuration tuning Solution

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.