jvm jvm parameter setting parameter Encyclopedia

jvm parameters Daquan

 

Transfer: http://blog.csdn.net/kthq/article/details/8618052

Parameter Description
-Xmx3550m: Set the maximum JVM heap memory for the 3550M.
-Xms3550m: Set initial JVM heap memory for the 3550M. This value can be set the same -Xmx, each JVM to avoid reallocate memory garbage collection completes.
-Xss128k: Sets the stack size for each thread. JDK5.0 after each thread stack size is 1M, before each thread stack size is 256K. The required memory size should be adjusted according to the application thread. At the same physical memory, reducing this value can generate more threads. However, the number of operating system threads within a process still limited, not unlimited generation, experience in 3000 and 5000. Note that: when a large (e.g.> 2MB) is set this value will degrade system performance to a large extent.
-Xmn2g: Set the size of the young generation 2G. In the case where the determined size of the entire heap memory, the young generation will increase the old generation is reduced, and vice versa. This value is related to the JVM garbage collection, a greater impact on system performance, the official recommended configuration for the entire heap size of 3/8.
-XX: NewSize = 1024m: the young generation initial value setting 1024M.
-XX: MaxNewSize = 1024m: Set the young generation a maximum of 1024M.
-XX: PermSize = 256m: initial value setting permanent generation 256M.
-XX: MaxPermSize = 256m: setting a maximum permanent generation of 256M.
-XX: NewRatio = 4: Set the young generation (including 1 and 2 Eden Survivor areas) the ratio of the old generation. Representation on behalf of the young generation older than 1: 4.
-XX: SurvivorRatio = 4: setting the ratio of area and Survivor Eden young generation area. 2 represents Survivor areas (JVM default heap memory in the young generation there are two equal-sized area Survivor) with a ratio of Eden region is 2: 4, i.e., a Survivor areas the total size of 1/6 of the young generation.
-XX: MaxTenuringThreshold = 7: If you move represents an object in the Survivor areas (relief space) 7 times garbage collection has not yet been entered old generation. If set to 0, then the younger generation of the object without Survivor areas, directly into the old generation, the need for a large amount of memory resident applications, doing so can improve efficiency. If this value is set to a large value, then the young generation objects will be copied many times in Survivor areas, which can increase the survival of objects in the young generation time, increasing the probability of objects in the young generation of garbage is recycled, reducing the frequency of Full GC doing so can improve service stability to some extent.
FAQ
-Xmn, -XX: NewSize / -XX: MaxNewSize, -XX: NewRatio 3 sets of parameters can affect the size of the young generation, in the case of mixed use, what the priorities are?
As follows:
High Priority: -XX: NewSize / -XX: MaxNewSize 
priority: -Xmn (The default equivalent -Xmn = -XX: NewSize = -XX:  ? MaxNewSize =)
Low priority: -XX: NewRatio 
recommended -Xmn parameter, because this parameter is simple, equivalent to a set NewSize / MaxNewSIze, and the two are equal, for a production environment. -Xmn with -Xms / -Xmx, to the heap memory layout is complete.
-Xmn argument is beginning to support in JDK 1.4.

Garbage collector selected
JVM is given three options: serial collector, the collector parallel, concurrent collector. Serial collector applies only to the case of a small amount of data, so the choice of the production environment is mainly parallel collector and concurrent collector.
By default JDK5.0 had previously been using a serial collector, if you want to use other collectors need to add the appropriate parameters at startup. After JDK5.0, JVM will be intelligent judgment based on the current system configuration.
Serial collector
-XX: + UseSerialGC: setting serial collector.
Parallel collector (certain priority)
-XX: + UseParallelGC: disposed parallel collector. This configuration is valid only for the young generation. That the young generation parallel collector, while still using the old generation of the serial collector.
-XX: ParallelGCThreads = 20: number of threads parallel collector configuration, namely: while the number of garbage collection threads together. This value is equal to the number of recommended configuration CPU.
-XX: + UseParallelOldGC: Configure old generation garbage collection is collected in parallel. JDK6.0 began to gather support for the old generation parallel.
-XX: MaxGCPauseMillis = 100: Set each of the young generation garbage collection maximum time (in milliseconds). If you can not meet this time, JVM will automatically adjust the size of the young generation to meet this time.
-XX: + UseAdaptiveSizePolicy: After setting this option, the parallel collector will automatically adjust the proportion of the young generation Eden area size and area size of Survivor, to achieve the minimum response time requirements of the target system or collection frequency and other indicators. This parameter is recommended when using the parallel collector, it has been opened.
Concurrent collector (response time priority)
-XX: + UseConcMarkSweepGC: i.e. CMS collect, on behalf of the old set concurrent collection. CMS is collecting new GC algorithm were introduced in later versions of JDK1.4. Its main demand for the scene is the importance of the response time is greater than the demand for throughput, capable of withstanding the garbage collection thread and application threads share CPU resources, and there are more long-lived objects applications. CMS collection target is to minimize the pause time applications, reducing the chance of Full GC occurs, use and application thread concurrent garbage collection thread to mark remove the old generation memory.
-XX: + UseParNewGC: Set concurrent collection on behalf of the young. CMS can be collected and used simultaneously. Above JDK5.0, JVM itself based on the system configuration settings, then there is no need to set this parameter.
-XX: CMSFullGCsBeforeCompaction = 0: Since concurrent collector does not organize memory space and compressed, it will fragment memory after a period of operation the parallel collector, reduced memory efficiency. Memory space compression and after finishing this parameter is set to run 0 times Full GC, began to organize memory compression and immediately after each Full GC.
-XX: + UseCMSCompactAtFullCollection: Open Compression and consolidation memory space, performed after the Full GC. It may affect performance, but it can eliminate the memory fragmentation.
-XX: + CMSIncrementalMode: collection mode setting increments. Generally applies to a single CPU case.
-XX: CMSInitiatingOccupancyFraction = 70: represents the old generation of memory using 70% to begin collecting the implementation of CMS to ensure that older generations have enough space to receive objects from the young generation, to avoid the occurrence of Full GC.
Other garbage collection parameters
-XX: + ScavengeBeforeFullGC: Full GC is superior to the young generation GC execution.
-XX: -DisableExplicitGC: unresponsive System.gc () code.
-XX: + UseThreadPriorities: Enabling local thread priority API. Even java.lang.Thread.setPriority () entered into force, it is not enabled invalid.
-XX: SoftRefLRUPolicyMSPerMB = 0: Soft references after the last accessed survive 0 milliseconds (JVM defaults to 1000 milliseconds).
-XX: TargetSurvivorRatio = 90: 90% of the allowed region is occupied Survivor (JVM default 50%). For improving utilization Survivor region.
Supplementary information parameter settings
-XX: -CITime: print consumption JIT compilation time.
-XX: ErrorFile = / hs_err_pid.log:. Error log or save data to the specified file.
-XX: HeapDumpPath = / java_pid.hprof:. Dump designated path when heap memory.
-XX: -HeapDumpOnOutOfMemoryError: Dump the heap at this time when the first encounter out of memory.
-XX: OnError = ";": ERROR after a fatal run custom commands.
-XX: OnOutOfMemoryError = ";": execute custom commands when the first encounter out of memory.
-XX: -PrintClassHistogram: Print press Ctrl columnar instance of a class in memory heap after Break +, with the JDK jmap -histo command.
-XX: -PrintConcurrentLocks: Press Ctrl + Break relevant information printed concurrent locking of the thread stack, with the JDK jstack -l command.
-XX: -PrintCompilation: print information when a method is compiled.
-XX: -PrintGC: print-related information every time GC.
-XX: -PrintGCDetails: print more information each time GC.
-XX: -PrintGCTimeStamps: print each GC timestamp.
-XX: -TraceClassLoading: loading information tracking classes.
-XX: -TraceClassLoadingPreorder: Tracking information is referenced to load all classes to.
-XX: -TraceClassResolution: Tracking the constant pool.
-XX: -TraceClassUnloading: Uninstall information tracking classes.
About parameter name and other
standard parameters (-), JVM must support all the functions of these parameters, and is backward compatible; for example:
-client-- setting JVM using Client mode, characterized by a faster start, but runtime performance and memory management efficiency is not high, typically used for client application development or debugging; directly in the 32-bit environment Java program to enable this mode by default.
-server-- set the JVM Server mode, characterized by a slower start, but a high runtime performance and memory management efficiency, suitable for production environments. This mode is enabled by default in the JDK environment with 64-bit capability.
Non-standard parameters (-X), the default JVM implementations function of these parameters, but does not guarantee that all JVM implementations are met, and does not guarantee backward compatibility;
non-stable parameters (-XX), each of these parameters will be JVM implementation different, may not be supported in the future, need to be used carefully;

the JVM service parameters tune combat
large-scale server case
to withstand massive access dynamic Web application
server configuration: 8 CPU, 8G MEM, JDK 1.6.X
parameter program:
-server -Xmx3550m -Xms3550m -Xmn1256m -Xss128k -XX: SurvivorRatio = 6 -XX: MaxPermSize = 256m -XX: ParallelGCThreads = 8 -XX: MaxTenuringThreshold = 0 -XX: + UseConcMarkSweepGC
tuning DESCRIPTION:
same JVM -Xmx and to avoid repeated re -Xms application memory. -Xmx equal to about half the size of system memory size, that make full use of system resources, and give safe operation of space systems.
-Xmn1256m set the young generation size is 1256MB. This value greater impact on system performance, Sun official recommended configuration for the entire size of the young generation heap 3/8.
-Xss128k set a lower thread stack to support the creation of more threads, support mass access to, and improve system performance.
-XX: SurvivorRatio = ratio Eden region Survivor region 6 is provided in the young generation. The system default is 8, according to a ratio set empirically to 6, the two regions with a Survivor Eden region is 2: 6, a Survivor young generation area 1/8 the total.
-XX: ParallelGCThreads = number of threads arranged parallel collector 8, i.e., while the garbage collection threads 8 together. This value is generally equal to the configuration and the number of CPU.
-XX: MaxTenuringThreshold = 0 is set garbage maximum age (the number of surviving young generation). If set to 0, then the younger generation of the object without Survivor areas directly into the old generation. For more application of the old generation efficiency can be improved; if this value is set to a higher value, the young generation objects will be copied many times in Survivor areas, which can increase the object and then the young generation of survival time, an increase in ie the probability of recovery of the young generation. According to the characteristics of dynamic Web applications to be accessible to mass, or its memory is cached to reduce direct access to DB, or be quickly recovered to support high concurrent massive request, so the memory objects in the young generation not survive multiple meaning, it can be directly into the old generation, according to practical application, this value is 0 is provided here.
-XX: + UseConcMarkSweepGC set up on behalf of concurrent old collection. CMS (ConcMarkSweepGC) collection target is to minimize the pause time applications, reducing the chance of Full GC occurs, use and application thread concurrent garbage collection thread to mark remove the old generation of memory, there is more suitable for long-life applications case cycle object.
Internal integration build server cases
of high-performance data processing tools for application
Server Configuration: 1 CPU, 4G MEM, JDK 1.6.X
parameters scheme:
-server -XX: PermSize = 196m -XX: MaxPermSize = 196m -Xmn320m -Xms768m -Xmx1024m
Tuning Description:
-XX: PermSize = 196m -XX: MaxPermSize = 196m the integrated construction of the characteristics of large-scale systems may need to load a large amount of compiled Java classes into memory, so a lot of good pre-assigned permanent generation memory is efficient and necessary.
-Xmn320m 3/8 the size of the young generation to follow the principle of the whole stack.
The system can be provided -Xms768m -Xmx1024m can withstand substantially heap memory size.

Transfer: http://blog.csdn.net/kthq/article/details/8618052

Parameter Description
-Xmx3550m: Set the maximum JVM heap memory for the 3550M.
-Xms3550m: Set initial JVM heap memory for the 3550M. This value can be set the same -Xmx, each JVM to avoid reallocate memory garbage collection completes.
-Xss128k: Sets the stack size for each thread. JDK5.0 after each thread stack size is 1M, before each thread stack size is 256K. The required memory size should be adjusted according to the application thread. At the same physical memory, reducing this value can generate more threads. However, the number of operating system threads within a process still limited, not unlimited generation, experience in 3000 and 5000. Note that: when a large (e.g.> 2MB) is set this value will degrade system performance to a large extent.
-Xmn2g: Set the size of the young generation 2G. In the case where the determined size of the entire heap memory, the young generation will increase the old generation is reduced, and vice versa. This value is related to the JVM garbage collection, a greater impact on system performance, the official recommended configuration for the entire heap size of 3/8.
-XX: NewSize = 1024m: the young generation initial value setting 1024M.
-XX: MaxNewSize = 1024m: Set the young generation a maximum of 1024M.
-XX: PermSize = 256m: initial value setting permanent generation 256M.
-XX: MaxPermSize = 256m: setting a maximum permanent generation of 256M.
-XX: NewRatio = 4: Set the young generation (including 1 and 2 Eden Survivor areas) the ratio of the old generation. Representation on behalf of the young generation older than 1: 4.
-XX: SurvivorRatio = 4: setting the ratio of area and Survivor Eden young generation area. 2 represents Survivor areas (JVM default heap memory in the young generation there are two equal-sized area Survivor) with a ratio of Eden region is 2: 4, i.e., a Survivor areas the total size of 1/6 of the young generation.
-XX: MaxTenuringThreshold = 7: If you move represents an object in the Survivor areas (relief space) 7 times garbage collection has not yet been entered old generation. If set to 0, then the younger generation of the object without Survivor areas, directly into the old generation, the need for a large amount of memory resident applications, doing so can improve efficiency. If this value is set to a large value, then the young generation objects will be copied many times in Survivor areas, which can increase the survival of objects in the young generation time, increasing the probability of objects in the young generation of garbage is recycled, reducing the frequency of Full GC doing so can improve service stability to some extent.
FAQ
-Xmn, -XX: NewSize / -XX: MaxNewSize, -XX: NewRatio 3 sets of parameters can affect the size of the young generation, in the case of mixed use, what the priorities are?
As follows:
High Priority: -XX: NewSize / -XX: MaxNewSize 
priority: -Xmn (The default equivalent -Xmn = -XX: NewSize = -XX:  ? MaxNewSize =)
Low priority: -XX: NewRatio 
recommended -Xmn parameter, because this parameter is simple, equivalent to a set NewSize / MaxNewSIze, and the two are equal, for a production environment. -Xmn with -Xms / -Xmx, to the heap memory layout is complete.
-Xmn argument is beginning to support in JDK 1.4.

Garbage collector selected
JVM is given three options: serial collector, the collector parallel, concurrent collector. Serial collector applies only to the case of a small amount of data, so the choice of the production environment is mainly parallel collector and concurrent collector.
By default JDK5.0 had previously been using a serial collector, if you want to use other collectors need to add the appropriate parameters at startup. After JDK5.0, JVM will be intelligent judgment based on the current system configuration.
Serial collector
-XX: + UseSerialGC: setting serial collector.
Parallel collector (certain priority)
-XX: + UseParallelGC: disposed parallel collector. This configuration is valid only for the young generation. That the young generation parallel collector, while still using the old generation of the serial collector.
-XX: ParallelGCThreads = 20: number of threads parallel collector configuration, namely: while the number of garbage collection threads together. This value is equal to the number of recommended configuration CPU.
-XX: + UseParallelOldGC: Configure old generation garbage collection is collected in parallel. JDK6.0 began to gather support for the old generation parallel.
-XX: MaxGCPauseMillis = 100: Set each of the young generation garbage collection maximum time (in milliseconds). If you can not meet this time, JVM will automatically adjust the size of the young generation to meet this time.
-XX: + UseAdaptiveSizePolicy: After setting this option, the parallel collector will automatically adjust the proportion of the young generation Eden area size and area size of Survivor, to achieve the minimum response time requirements of the target system or collection frequency and other indicators. This parameter is recommended when using the parallel collector, it has been opened.
Concurrent collector (response time priority)
-XX: + UseConcMarkSweepGC: i.e. CMS collect, on behalf of the old set concurrent collection. CMS is collecting new GC algorithm were introduced in later versions of JDK1.4. Its main demand for the scene is the importance of the response time is greater than the demand for throughput, capable of withstanding the garbage collection thread and application threads share CPU resources, and there are more long-lived objects applications. CMS collection target is to minimize the pause time applications, reducing the chance of Full GC occurs, use and application thread concurrent garbage collection thread to mark remove the old generation memory.
-XX: + UseParNewGC: Set concurrent collection on behalf of the young. CMS can be collected and used simultaneously. Above JDK5.0, JVM itself based on the system configuration settings, then there is no need to set this parameter.
-XX: CMSFullGCsBeforeCompaction = 0: Since concurrent collector does not organize memory space and compressed, it will fragment memory after a period of operation the parallel collector, reduced memory efficiency. Memory space compression and after finishing this parameter is set to run 0 times Full GC, began to organize memory compression and immediately after each Full GC.
-XX: + UseCMSCompactAtFullCollection: Open Compression and consolidation memory space, performed after the Full GC. It may affect performance, but it can eliminate the memory fragmentation.
-XX: + CMSIncrementalMode: collection mode setting increments. Generally applies to a single CPU case.
-XX: CMSInitiatingOccupancyFraction = 70: represents the old generation of memory using 70% to begin collecting the implementation of CMS to ensure that older generations have enough space to receive objects from the young generation, to avoid the occurrence of Full GC.
Other garbage collection parameters
-XX: + ScavengeBeforeFullGC: Full GC is superior to the young generation GC execution.
-XX: -DisableExplicitGC: unresponsive System.gc () code.
-XX: + UseThreadPriorities: Enabling local thread priority API. Even java.lang.Thread.setPriority () entered into force, it is not enabled invalid.
-XX: SoftRefLRUPolicyMSPerMB = 0: Soft references after the last accessed survive 0 milliseconds (JVM defaults to 1000 milliseconds).
-XX: TargetSurvivorRatio = 90: 90% of the allowed region is occupied Survivor (JVM default 50%). For improving utilization Survivor region.
Supplementary information parameter settings
-XX: -CITime: print consumption JIT compilation time.
-XX: ErrorFile = / hs_err_pid.log:. Error log or save data to the specified file.
-XX: HeapDumpPath = / java_pid.hprof:. Dump designated path when heap memory.
-XX: -HeapDumpOnOutOfMemoryError: Dump the heap at this time when the first encounter out of memory.
-XX: OnError = ";": ERROR after a fatal run custom commands.
-XX: OnOutOfMemoryError = ";": execute custom commands when the first encounter out of memory.
-XX: -PrintClassHistogram: Print press Ctrl columnar instance of a class in memory heap after Break +, with the JDK jmap -histo command.
-XX: -PrintConcurrentLocks: Press Ctrl + Break relevant information printed concurrent locking of the thread stack, with the JDK jstack -l command.
-XX: -PrintCompilation: print information when a method is compiled.
-XX: -PrintGC: print-related information every time GC.
-XX: -PrintGCDetails: print more information each time GC.
-XX: -PrintGCTimeStamps: print each GC timestamp.
-XX: -TraceClassLoading: loading information tracking classes.
-XX: -TraceClassLoadingPreorder: Tracking information is referenced to load all classes to.
-XX: -TraceClassResolution: Tracking the constant pool.
-XX: -TraceClassUnloading: Uninstall information tracking classes.
About parameter name and other
standard parameters (-), JVM must support all the functions of these parameters, and is backward compatible; for example:
-client-- setting JVM using Client mode, characterized by a faster start, but runtime performance and memory management efficiency is not high, typically used for client application development or debugging; directly in the 32-bit environment Java program to enable this mode by default.
-server-- set the JVM Server mode, characterized by a slower start, but a high runtime performance and memory management efficiency, suitable for production environments. This mode is enabled by default in the JDK environment with 64-bit capability.
Non-standard parameters (-X), the default JVM implementations function of these parameters, but does not guarantee that all JVM implementations are met, and does not guarantee backward compatibility;
non-stable parameters (-XX), each of these parameters will be JVM implementation different, may not be supported in the future, need to be used carefully;

the JVM service parameters tune combat
large-scale server case
to withstand massive access dynamic Web application
server configuration: 8 CPU, 8G MEM, JDK 1.6.X
parameter program:
-server -Xmx3550m -Xms3550m -Xmn1256m -Xss128k -XX: SurvivorRatio = 6 -XX: MaxPermSize = 256m -XX: ParallelGCThreads = 8 -XX: MaxTenuringThreshold = 0 -XX: + UseConcMarkSweepGC
tuning DESCRIPTION:
same JVM -Xmx and to avoid repeated re -Xms application memory. -Xmx equal to about half the size of system memory size, that make full use of system resources, and give safe operation of space systems.
-Xmn1256m set the young generation size is 1256MB. This value greater impact on system performance, Sun official recommended configuration for the entire size of the young generation heap 3/8.
-Xss128k set a lower thread stack to support the creation of more threads, support mass access to, and improve system performance.
-XX: SurvivorRatio = ratio Eden region Survivor region 6 is provided in the young generation. The system default is 8, according to a ratio set empirically to 6, the two regions with a Survivor Eden region is 2: 6, a Survivor young generation area 1/8 the total.
-XX: ParallelGCThreads = number of threads arranged parallel collector 8, i.e., while the garbage collection threads 8 together. This value is generally equal to the configuration and the number of CPU.
-XX: MaxTenuringThreshold = 0 is set garbage maximum age (the number of surviving young generation). If set to 0, then the younger generation of the object without Survivor areas directly into the old generation. For more application of the old generation efficiency can be improved; if this value is set to a higher value, the young generation objects will be copied many times in Survivor areas, which can increase the object and then the young generation of survival time, an increase in ie the probability of recovery of the young generation. According to the characteristics of dynamic Web applications to be accessible to mass, or its memory is cached to reduce direct access to DB, or be quickly recovered to support high concurrent massive request, so the memory objects in the young generation not survive multiple meaning, it can be directly into the old generation, according to practical application, this value is 0 is provided here.
-XX: + UseConcMarkSweepGC set up on behalf of concurrent old collection. CMS (ConcMarkSweepGC) collection target is to minimize the pause time applications, reducing the chance of Full GC occurs, use and application thread concurrent garbage collection thread to mark remove the old generation of memory, there is more suitable for long-life applications case cycle object.
Internal integration build server cases
of high-performance data processing tools for application
Server Configuration: 1 CPU, 4G MEM, JDK 1.6.X
parameters scheme:
-server -XX: PermSize = 196m -XX: MaxPermSize = 196m -Xmn320m -Xms768m -Xmx1024m
Tuning Description:
-XX: PermSize = 196m -XX: MaxPermSize = 196m the integrated construction of the characteristics of large-scale systems may need to load a large amount of compiled Java classes into memory, so a lot of good pre-assigned permanent generation memory is efficient and necessary.
-Xmn320m 3/8 the size of the young generation to follow the principle of the whole stack.
The system can be provided -Xms768m -Xmx1024m can withstand substantially heap memory size.

Guess you like

Origin www.cnblogs.com/qyx2019/p/10980012.html