Eclipse running optimization (JVM parameter configuration)

Source: Internet
Author: User

Refer:

Http://hi.baidu.com/hero706309/blog/item/2b85988d3641b6e2503d922b.html

 

(Http://howsun.blog.sohu.com/182790343.html)

-- Set the maximum heap size and the minimum heap size. The two are the same as the fixed size. This will prevent memory expansion in the old age from causing additional GC. Of course, it will also occupy more memory. Use with caution when the system memory is insufficient.

-Xms512m

-Xmx512m

-- Increase the memory size of the young generation. Reduce minor GC.

-Xmn164m

-- This is the permanent generation size. The default value is 64 m, which is increased to 96 m. fixed size, reduce GC caused by expansion

-XX: permsize = 96 m

-XX: maxpermsize = 96 m

-- Remove bytecode Verification

-Xverify: None

-- Shield the display and call GC.

-XX: + disableexplicitgc

-- Disable garbage collection to eliminate the overhead caused by multiple loads and dismounting the same class.

-Xnoclassgc

-- Specify the most suitable CMS Garbage Collector for multi-task parallel execution

-XX: + useparnewgc

-XX: + useconcmarksweepgc

-- Modify the default memory usage for triggering full GC in the old age to 85%.

-XX: cmsinitiatingoccupancyfraction = 85

# My configuration. -VM-c: \ Java \ jdk1.6.0 _ 30 \ bin \ javaw.exe-startupplugins/org. eclipse. equinox. launcher_1.1.0.v20100507.jar -- launcher. libraryplugins/org. eclipse. equinox. launcher. win32.win32. x86_1.1.1.R36x_v20100810-productorg.eclipse.epp.package.jee.product -- launcher. defaultactionopenfile -- launcher. XXMaxPermSize128M-showsplashorg.eclipse.platform -- launcher. xxmaxpermsize128m -- launcher. defaultActionopenFile-vmargs-Dosgi.requiredJavaVersion = 1.5-xverify: None-XX: + DisableExplicitGC-Xms512M-Xmx512M-Xmn164m-XX: permsize = 96m-xx: maxpermsize = 96m-xx: + useparallelgc-XX: cmsinitiatingoccupancyfraction = 85

 

 

Transferred from:

Http://blog.chinaunix.net/space.php? Uid = 10178376 & Do = Blog & id = 100985

-Vmargs-xms128m-xmx512m-XX: permsize = 64 m-XX: maxpermsize = 128 m
There are several questions:
1. What are the meanings of each parameter?
2. Why can eclipse be started after I set-xmx and-XX: maxpermsize to 512m on some machines, but some machines cannot be started?
3. Why didn't eclipse execute the corresponding settings when writing the above parameters to the eclipse. ini file?

Let's answer them one by one.

1. What are the meanings of each parameter?

In the parameters-vmargs indicates setting JVM parameters, so the following are actually JVM parameters. First, let's take a look at the JVM memory management mechanism, and then explain the meaning of each parameter.

Heap and non-heap memory
According to the official statement: "A Java virtual machine has a heap. The heap is the runtime data area, and the memory of all class instances and arrays is allocated from this place. The heap is created when the Java Virtual Machine is started ." "Memory outside of the heap in JVM is called non-heap memory )". JVM manages two types of memory: heap and non-heap. In short, heap is the memory available for Java code and is reserved for developers. Non-heap is reserved for JVM, therefore, the method area, JVM internal processing or optimization of the required memory (such as the code cache after JIT compilation), each class structure (such as the runtime data pool, field and method data) the methods and constructor code are all in non-heap memory.
Heap Memory Allocation
The initial memory allocated by JVM is specified by-XMS. The default value is 1/64 of the physical memory. The maximum memory allocated by JVM is specified by-xmx. The default value is 1/4 of the physical memory. By default, when the free heap memory is less than 40%, the JVM will increase the heap until the maximum limit of-xmx. When the free heap memory is greater than 70%, the JVM will reduce the minimum limit of heap until-XMS. Therefore, the server generally sets-XMS and-xmx to be equal to each other to avoid adjusting the heap size after each GC.
Non-heap memory allocation
JVM uses-XX: permsize to set the non-heap memory initial value. The default value is 1/64 of the physical memory. The maximum non-heap memory size is set by XX: maxpermsize. The default value is 1/4 of the physical memory.
JVM memory limit (maximum)
First, JVM memory is limited to the actual maximum physical memory (nonsense! If the physical memory is infinitely large, the maximum JVM memory has a great relationship with the operating system. Simply put, although the 32-bit processor has a controllable memory space of 4 GB, the specific operating system will impose a limit, this limit is generally 2 GB-3 GB (1.5 GB-2 GB in windows and 2 GB-3 GB in Linux ), the 64-bit and above processors will not be limited.
2. Why can eclipse be started after I set-xmx and-XX: maxpermsize to 512m on some machines, but some machines cannot be started?

Through the introduction of JVM memory management, we have learned that JVM memory includes two types: heap memory and non-heap memory. In addition, the maximum JVM memory depends on the actual physical memory and operating system. Therefore, setting VM parameters causes program startup failure mainly due to the following reasons:

1) In the parameter, the value of-XMS is greater than-xmx, or the value of-XX: permsize is greater than-XX: maxpermsize;

2)-xmx value and-XX: The sum of maxpermsize exceeds the maximum JVM memory limit, such as the maximum memory limit of the current operating system or the actual physical memory. Speaking of the actual physical memory, it should be noted that if your memory is 1024 MB, but it is not likely to be 1024 MB in the actual system, because some of them are occupied by hardware.

3. Why didn't eclipse execute the corresponding settings when writing the above parameters to the eclipse. ini file?

Why is the same parameter valid in the shortcut or command line and invalid in the eclipse. ini file? This is because we have not followed the setting rules of the eclipse. ini file:

Parameters are in the form of "item value". If there is a space in the middle, you need to wrap it. If there is a space in the value, you need to include it in double quotation marks. For example, we use the-VM c: \ Java \ jre1.6.0 \ bin \ javaw.exe parameter to set the virtual machine. In the eclipse. ini file, we need to write it as follows:

-VM
C: \ Java \ jre1.6.0 \ bin \ javaw.exe
As mentioned above, the final parameter can be written in eclipse. ini as follows:

-Vmargs
-Xms128m
-Xmx512m
-XX: permsize = 64 m
-XX: maxpermsize = 128 m
The actual running result can be viewed through the "configuration details" button in the "help"-"about eclipse SDK" window in eclipse.

Note that the eclipse. ini file in the eclipse compressed package contains the following content:

-Showsplash
Org. Eclipse. Platform
-- Launcher. xxmaxpermsize
256 m
-Vmargs
-Xms40m
-Xmx256m
Among them,-launcher. xxmaxpermsize (note that there are two connection lines at the top) and-XX: the meaning of maxpermsize.pdf is similar. I think the only difference is that the parameter set at startup of eclipse.exe, and the latter is the parameter in JVM used by eclipse. In fact, you can set one of the two, so here you can comment out-launcher. xxmaxpermsize and use # In the next line.

3. Other startup parameters. If you have a dual-core CPU, you can try this parameter:

-XX:+UseParallelGC

Enables faster GC execution. (Only the newly added GC parameters in JDK 5)

Heap size settings
The maximum heap size in JVM has three restrictions: the data model (32-BT or 64-bit) of the relevant operating system; the available virtual memory limit of the system; and the available physical memory limit of the system. Generally, 32-bit systems are limited to Gbps ~ 2 GB; 64 indicates that the operating system has unlimited memory. In Windows Server 2003, 1478 GB physical memory, and JDK, the maximum value is MB.
Typical settings:
Java-xmx3550m-xms3550m-xmn2g-xss128k
-Xmx3550m: sets the maximum available JVM memory to 3550 MB.
-Xms3550m: Set JVM to enable the memory to be 3550 MB. This value can be set to the same as-xmx to avoid JVM re-allocating memory after each garbage collection.
-Xmn2g: Set the young generation to 2 GB. Total heap size = size of the young generation + size of the old generation + size of the persistent generation. The permanent generation usually has a fixed size of 64 M. Therefore, increasing the size of the young generation will reduce the size of the old generation. This value has a great impact on the system performance. Sun officially recommends 3/8 of the total heap configuration.
-Xss128k: Set the stack size of each thread. After JDK 256, the size of each thread stack is 1 MB, and the size of each previous thread stack is K. The memory size required for more application threads is adjusted. Reduce this value to generate more threads in the same physical memory. However, the operating system still has a limit on the number of threads in a process. It cannot be generated infinitely. The experience is between 3000 and ~ About 5000.
Java-xmx3550m-xms3550m-xss128k-XX: newratio = 4-XX: Export vorratio = 4-XX: maxpermsize = 16 m-XX: maxtenuringthreshold = 0
-XX: newratio = 4: Set the ratio of the young generation (including Eden and two region vor regions) to the old generation (excluding the permanent generation ). If this parameter is set to 4, the ratio of the young generation to the old generation is, and the young generation accounts for 1/5 of the entire stack.
-XX: Region vorratio = 4: Set the ratio of Eden to region vor in the young generation. If this parameter is set to 4, the ratio of two vor zones to One Eden zone is, and one vor zone accounts for 1/6 of the young generation.
-XX: maxpermsize = 16 M: sets the persistent generation size to 16 m.
-XX: maxtenuringthreshold = 0: sets the maximum age of spam. If it is set to 0, the young generation object directly enters the old generation without going through the VOR area. For applications with many older generations, the efficiency can be improved. If this value is set to a greater value, the young generation object will be copied multiple times in the same vor area, which can increase the survival time of the young generation object, added an overview of being recycled in the young generation.
Collector Selection
JVM provides three options: Serial collector, parallel collector, and concurrent collector, but the serial collector is only applicable to small data volumes. Therefore, the options here are mainly for parallel collector and concurrent collector. By default, jdk5.0 used a serial collector before. To use another collector, you must add the relevant parameters at startup. After jdk5.0, the JVM will judge based on the current system configuration.
Throughput-first parallel collector
As described above, parallel collectors are mainly aimed at reaching a certain throughput and are suitable for Science and Technology and background processing.

 

From:

Http://www.oschina.net/question/12_11854

A: heapsize for JVM parameter configuration

-Xmx
Specifies the maximum heap size of the JVM, for example,-xmx2g (remember ten millions, but there is no equal sign)

-XMS
Specify the minimum heap size of the JVM, for example,-xms2g (do not remember, but there is no equal sign). For highly concurrent applications, we recommend that you use the same size as-xmx, to avoid the performance impact caused by memory shrinkage/sudden increase, remember that it is OK if the two values are the same.

-Xmn
Specify the newgeneration size in JVM, for example,-xmn256m. This parameter will affect the performance, so you need to configure it. If your program requires a large amount of temporary memory, we recommend that you set it to 512 MB, reduce the value as much as possible. Generally, 128/256 is enough for use. The higher the GC efficiency, the higher the system performance, generally, it is okay to configure the data-based system to an acceptable lower limit.

-XX: permsize =
Specify the minimum permgeneration value in JVM, for example,-XX: permsize = 32 m. This parameter depends on your actual situation. In the production environment, this parameter must be debugged to obtain the most accurate value, which often results in memory overflow in this region.

-XX: maxpermsize =
Specify the maximum value of permgeneration (permanent generation), for example,-XX: maxpermsize = 64 m

-XSS
Specifies the thread compaction size, for example,-xss128k. Generally, 256 k is required for applications in the webx framework. If your program has a large-scale recursive behavior, consider setting it to 512 K/1 m. This requires a comprehensive test. However, K is already very large. This parameter has a great impact on performance. Less allocation means you can get several more threads, but you still have to get the token based on your application.

-XX: newratio =
Specify the ratio of oldgenerationheapsize to newgeneration in JVM. this parameter is invalid when cmsgc is used, for example,-XX: newratio = 2.

-XX: Required vorratio =
Specify the heapsize ratio of edenspace in newgeneration to the heapsize of a region vorspace.-XX: Region vorratio = 8. In this case, when the total newgeneration is 10 MB, edenspace is 8 Mb.

-XX: minheapfreeratio =
When the jvmheap usage is less than N, heap is reduced. xmx = XMS is invalid, for example,-XX: minheapfreeratio = 30.

-XX: maxheapfreeratio =
When the jvmheap usage is greater than N, heap expands. xmx = XMS is invalid, for example,-XX: maxheapfreeratio = 70.

-XX: largepagesizeinbytes =
Page size of javaheap, for example,-XX: largepagesizeinbytes = 128 m

B: JVM parameter configuration garbagecollector

-XX: + useparallelgc
This parameter specifies that parallelcollector is used in newgeneration to collect data in parallel, pause appthreads, and start multiple garbage collection threads. It cannot be used with cmsgc. the system has a higher ton of spam, but there will be a longer period of apppause. This GC can be used for background system tasks.

-XX: parallelgcthreads =
Specify the number of threads started during parallelcollection. The default value is the number of physical processors,

-XX: + useparalleloldgc
Specify parallelcollector in oldgeneration

-XX: + useparnewgc
It is specified that parallelcollector is used in newgeneration and is an upgraded version of useparallelgc. It has better performance or advantages and can be used with cmsgc.

-XX: + cmsparallelremarkenabled
Minimize mark time when useparnewgc is used

-XX: + useconcmarksweepgc
Specify that concurrentcmarksweepgc, gcthread, and appthread are used concurrently in oldgeneration (pauseappthread during init-mark and remark). apppause is short and suitable for interactive systems such as Webserver

-XX: + usecmscompactatfullcollection
Prevent memoryfragmention and organize liveobject to reduce memory fragments when concurrentgc is used.

-XX: cmsinitiatingoccupancyfraction =
Indicates to start concurrentcollector after oldgeneration uses the N % ratio. The default value is 68, for example,-XX: cmsinitiatingoccupancyfraction = 70.

-XX: + usecmsinitiatingoccupancyonly
Indicates that the concurrentcollector starts collection only after oldgeneration uses the initialization ratio.

C: Other JVM parameter configurations

-XX: maxtenuringthreshold =
After an object has been transferred to the oldgeneration (oldgeneration) after N times of younggc (GC in the new generation), the default value of the object in Java 6 of linux64 is 15, this parameter is invalid for throughputcollector, for example,-XX: maxtenuringthreshold = 31.

-XX: + disableexplicitgc
Disable fullgc called in Java programs, such as system. GC. This parameter is usually required to improve system performance.

-XX: + usefastaccessormethods
Convert get and set methods into local code

-XX: + printgcdetails
This parameter is used to collect details of garbage collection.

-XX: + printgctimestamps
Time Division of garbage collection

-XX: + printgcapplicationstoppedtime
System pause time caused by GC during garbage collection

D: List of collection methods for the new and old generations by several groups of GC:

Specify the generation GC mode, the old generation GC Mode

 

-XX: + useserialgc serial GC

 

-XX: + useparallelgc parallel GC collection

 

-XX: + useconemarksweepgc parallel GC concurrent GC

 

-XX: + useparnewgc parallel GC serial GC

 

-XX: + useparalleloldgc parallel GC collection

 

-XX: + useconemarksweepgc

-XX: + useparnewgc serial GC concurrent GC

 

Unsupported combination 1,-XX: + useparnewgc-XX: + useparalleloldgc

2.-XX: + useparnewgc-XX: + useserialgc

 

Summary:

Serial collection: Serial collection uses a single thread to process all garbage collection tasks. Because multi-thread interaction is not required, the implementation is easy and the efficiency is relatively high. However, its limitations are also obvious, that is, the advantage of being unable to use multi-processor is suitable for single-processor machines.

 

Parallel collection: Parallel collection uses multiple threads to process garbage collection, which is fast and efficient. In theory, the larger the number of CPUs, the more advantageous the parallel collector will be.

 

Concurrent collection: Compared to serial collection and parallel collection, the first two must suspend the entire runtime environment for garbage collection (that is, only one GC thread is running, other brothers have to stop their hands to wait for the execution to complete). Therefore, the system will obviously suspend the garbage collection process, and the suspension time will be longer and longer because of the larger heap.

 

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.