Java Memory settings PermGen space and so on

Source: Internet
Author: User


The solution is as follows:

Add the following two lines to the Eclipse.ini configuration file
-xx:permsize=128m
-xx:maxpermsize=128m

After adding 2 lines, my Eclipse.ini file looks like this:

-showsplash
Org.eclipse.platform
--launcher. Xxmaxpermsize
512m
-vmargs
-xms256m
-xmx512m
-xx:permsize=128m
-xx:maxpermsize=128m

The size of the memory here depends on your physical memory.

From the information on the Internet to see permsize bigger is certainly better, and it is best to set permsize and MaxPermSize as large. The reasons are as follows:
PermSize and MaxPermSize can also improve performance to some extent if set to the same, because PermSize will need to transfer the data in constant change. If fixed, it can reduce the performance loss of each extended permsize.




1, PermGen space Introduction

PermGen space is the full name of the permanent Generation spaces, refers to the memory of the permanent storage area Outofmemoryerror:permgen from the surface is the memory benefits, the solution must also be to increase memory.

Talk about why memory benefits out:
(1) This section is used to store class and meta information, class is placed in the PermGen space area when it is load, and it differs from the heap area where the instance is stored.
(2) GC (garbage Collection) does not clean up the PermGen space during the runtime of the main program, so if your app will load a lot of classes, it is likely that PermGen space error will occur. This error is common when the Web server is pre compile the JSP.

If your web app uses a large number of third-party jars that are larger than the JVM default size (4M), this error message is generated.


Workaround: Manually set the MaxPermSize size

Modify tomcat_home/bin/catalina.sh and add the following line to the echo "Using catalina_base: $CATALINA _base":
Java_opts= "-server-xx:permsize=64m-xx:maxpermsize=128m
Recommendation: Move the same third-party jar files to the Tomcat/shared/lib directory, which can reduce the memory consumption of the jar document.





Java is automatically recycled memory, but applications, especially server programs, are best to specify memory allocation limits based on business conditions. Failure to do so may cause the application to be out of downtime.

Illustrate the meaning of an example:
-xms128m
Represents JVM Heap (heap memory) minimum size 128MB, initial allocation
-xmx512m
Represents the maximum allowable size of the JVM Heap (heap memory) 256MB, on demand.

Note: If-XMX is not specified or is specified to be small, the application may cause a java.lang.OutOfMemory error, which is not throwable by the JVM and cannot be captured with Try...catch.

PermSize and MaxPermSize indicate that the virtual machine is a Java permanent build object (permanate generation) such as a class object, a method object, these reflective (reflective) objects, that allocate memory limits. These memory is not included in the heap (heap memory) area.

-XX:PERMSIZE=64MB minimum size, initial allocation
-XX:MAXPERMSIZE=256MB maximum allowable allocation size, on demand
Too small will lead to: Java.lang.OutOfMemoryError:PermGen space

The MaxPermSize defaults are related to the-server-client option.
The default maxpermsize for the-server option is 64m
The default maxpermsize for the-client option is 32m


Experience:
1, careful with the minimum limit option Xms,permsize has saved system resources.
This is transferred from the following URL: http://hi.baidu.com/haoh/blog/item/2a76267f67177d0228388a80.html









The previous java_opts was-xms 520m-xmx 1220M-XSS 15120k +xx:aggressiveheap
This java_opts has made 2 fatal mistakes:
1. +xx:aggressiveheap will make Xms 1220m meaningless. This parameter lets the JVM ignore the xmx parameter, eats up a G-physical memory crazily, and then eats up a g swap.
In addition, xmx as the maximum amount of memory allowed to be used by the JVM should not exceed 90% of the physical memory.
And the reason why this parameter is used, because it is not added, JBoss will be running a day or so after the rapid collapse of the machine class is, or even appeared half an hour on the collapse of the situation.
The reason to use this parameter to run the server with swap is to make the following error:
2.-XSS 15120k
This allows JBoss to consume 15M of memory for each additional thread (thread), and the best value should be 128K, and the default value might be 512k.
This is when JBoss just started, there are 200Mb of memory surplus, but will run out quickly in one hours, because the server's threads is increasing rapidly. The first 3 days, eat more than 80Mb of swap every day. On the fourth day began to stabilize. This spring festival holidays outside, observed this phenomenon, but do not understand the reason: the server after the thread reached 100, generally no longer add new threads, the new increase in use, will be quickly destroy,? a gown Mei which 诖 play not Jue  side 诖 Air Chan lively qinglie  the non-segmental lan Pepper  Jin? The threads used by 1.25-2.10 are basically created by 1.21-1.23, so no new memory is consumed. The server continued to run, and thus greatly exceeded my 5-day expectation and reached 20 days.
The changes made yesterday:
1. Modify Java_opts, remove +xx:aggressiveheap, and modify XSS. Now the java_opts is:
-xms 520m-xmx 900M-XSS 128k
2. Modify Deploy/jbossweb-tomcat55.sar/service.xml
Drop the MaxThreads from the default 250 to 75 based on current traffic, and use JBoss 4 to default to 2 parameters that are not written in the standard Service.xml and JBoss 3 writes: maxsparsethreads= 55,minsparsethreads=25
3. The oracle-ds.xml has been modified to reduce the maximum number of connections by 150 to 50.
4. Removed some unused services








JVM Memory java_opts parameter Description

I often do this to set the server-side jvm:java_opts= "-server-xms2048m-xmx2048m-xss512k"

-server: Be sure to be the first parameter, performance at multiple CPUs good Liu Bing written on 2008-12-25 12:40
-XMS: Initial heap size, minimum memory used, higher CPU performance should be set larger
-xmx:java heap maximum, maximum memory used Liu Bing written on 2008-12-25 12:40
The above two values are the minimum and maximum memory allocated to the JVM, depending on the size of the hardware physical memory and are recommended to be half of the physical memory. Liu Bing written on 2008-12-25 12:40
-xx:permsize: Set memory for permanent storage area Liu Bing written on 2008-12-25 12:40
-xx:maxpermsize: Set maximum memory permanent Save area Liu Bing written on 2008-12-25 12:40
-xx:maxnewsize: Liu Bing written on 2008-12-25 12:40
-XSS 15120 This allows JBoss to consume 15M of memory for each additional thread (thread), and the best value should be 128K, which seems to be 512k. Liu Bing written on 2008-12-25 12:40
+xx:aggressiveheap will make XMS meaningless. This parameter lets the JVM ignore the xmx parameter, eats up a G-physical memory crazily, and then eats up a g swap. Liu Bing written on 2008-12-25 12:40
-XSS: Stack size per thread Liu Bing written on 2008-12-25 12:40
-VERBOSE:GC Real Garbage Collection information Liu Bing written on 2008-12-25 12:40
-XLOGGC:GC.LOG Specifies garbage collection log file Liu Bing written on 2008-12-25 12:40
The heap size of the-xmn:young generation, typically set to Xmx 3, 4, Liu Bing written on 2008-12-25 12:40
-XX:+USEPARNEWGC: Shorten minor collection Time Liu Bing written on 2008-12-25 12:40
-XX:+USECONCMARKSWEEPGC: Shorten major collection Time Liu Bing written on 2008-12-25 12:40
Tip: This option is more appropriate when the heap size is larger and the major collection time is longer.








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.