April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

JVM

JVM parameters set whether you know, here and share with you, including JVMHeap regional distribution, JVM’s two GC threads and Stack set and several other parts, I believe that this introduction to your study will be helpful.

Detailed JVM parameter settings

JVMHeap regional distribution:

JavaHeap is divided into three zones, Young, Old and Permanent. Young district saved vast majority of newly instantiated object, when the area is filled, triggering local GC, GC will Young local area emptied, still referenced objects will be moved to Old area. When the Old district no longer be filled, it will trigger FullGC, finally able to reclaim space recycling. Permanent district stands PermanentGenerationspace, permanent area for the storage of such Class and Method Meta information such Class in the Load when they were placed in the area. It is also responsible for maintaining the other reflective objects, because the reflected object essentially generate some metadata can not be recycled, so that the next reflection reuse.

General Whether local GC (GarbageCollection) or FullGC BE LIABLE PermGenspace to clean up. But if your lot CLASS LOAD Application will then likely overflow error occurs PermGenspace

There are two JVM GC threads:

The first thread is responsible for recycling JVMHeap the Young area.

The second thread in the Heap insufficient, traversal Heap, the Young district upgraded to Older area. Older area equal to the size-Xmx minus the-Xmn,-Xms value can not be set too large, because the second thread is forced to run will reduce the performance of the JVM.

GC may cause frequent causes are:

1, within a program called System. gc () or Runtime. gc ().

2, a number of middleware software call your own GC method, then you need to set parameters ban these GC.

3, Java’s Heap is too small, the general default Heap values ??are very small.

4, the frequent instances of objects, Release object. At this point try to save and reuse objects, such as using StringBuffer () and String ().

If you find that every time the GC, Heap the remaining space will be 50% of the total space, which means you Heap in a healthy state. Many Server side Java program after each GC is best to have 65% of the remaining space.

Server side will suggest the best JVM-Xms and-Xmx to the same value. To optimize the GC, best to let-Xmn-Xmx value is approximately equal to 1/3. A GUI program preferably every 10-20 seconds between run once GC, every half a second to complete. Although it will increase the size of Heap reduce the frequency of GC, but also increase the GC runs every time. And GC runs, all user threads will be suspended, that is, during GC, Java applications do not do any work, which in the GUI interface will very much affect the user experience.

Stack settings

1, each thread has his own Stack.

2,-Xss Stack size specified for each thread

3, Stack size limits the number of threads. Stack too big or too small may cause memory leakage

GC hardware environment also affect the efficiency of such kind of machines, the memory, swap space and CPU quantity. For example: If your program needs to create a lot of frequent transient objects (can not be serialized) will cause the JVM frequent GC. In this case you can increase the machine’s memory, to reduce the Swap space usage.

GC a total of 4 minutes:

1, the first single-threaded GC, is the default GC. The GC is suitable for single-CPU machines.

2, the second is ThroughputGC, is multithreaded GC, for multi-CPU, using a large number of threads the program. The second GC and GC similar to the first, except that the GC in the collection Young area is multi-threaded, but in the Old District, and the first, still single-threaded. -XX: + UseParallelGC parameter to start ThroughputGC.

3, the third is ConcurrentLowPauseGC, similar to the first, for multi-CPU, and require shorter procedures stagnation caused due to GC time. The GC can be recovered in the Old district while running the application. -XX: + UseConcMarkSweepGC parameter to start the GC.

4, the fourth is IncrementalLowPauseGC, for applications that require shortening caused by the program due to stagnation of the time GC. The GC can be recovered in the Young area while recovering a portion of Old Area object. -Xincgc parameter to start the GC.

JVM configuration parameters

1, heapsize

-Xmx

Specifies the maximum jvm heap size, such as:-Xmx = 2G

-Xms

Specifies the minimum jvm heap size, such as:-Xms = 2G, highly concurrent applications, proposals and-Xmx as to prevent shrinkage because of memory / performance impact of a sudden increase.

-Xmn

Specifies the size of the jvm YoungGeneration, such as:-Xmn256m. This parameter is affecting performance, if your program requires more temporary memory, it is recommended to set to 512M, if less, to minimize this value, generally 128/256 is sufficient to use.

Specify the jvm PermGeneration minimum, such as:-XX: PermSize = 32m. This parameter need to see your actual situation. You can see in the end how much jmap command.

Specifies the maximum PermGeneration, such as:-XX: MaxPermSize = 64m

-Xss

Zhan specified thread size, such as:-Xss128k, in general, webx framework application requires 256K. If your application has a large-scale recursive behavior, consider setting to 512K/1M. This requires comprehensive testing to know. However, 256K has been great. This parameter has the greatest impact on performance.

Specify the jvm OldGenerationheapsize with NewGeneration ratio in the case of using this parameter CMSGC failure, such as:-XX: NewRatio = 2 (default)

Specify NewGeneration in EdenSpace with a SurvivorSpace proportion of heapsize,-XX: SurvivorRatio = 8, then a total of 10M NewGeneration case, EdenSpace of 8M

Specifies jvmheap In the case of usage is less than n, heap shrink, Xmx == Xms invalid case, as:-XX: MinHeapFreeRatio = 30

Specifies jvmheap the usage case is greater than n, heap for expansion, Xmx == Xms invalid case, as:-XX: MaxHeapFreeRatio = 70

Specifies the Java heap pagination page size, such as 128M

2, garbagecollector

-XX: + UseParallelGC

Specifies YoungGeneration use parallelcollector, parallel collector, pause appthreads, simultaneously start multiple garbage collection thread, can not CMSGC together. The amount of system t spit priority, but there will be a long long time apppause, background system task can use this GC

Specify parallelcollection thread started when the number, the default is the number of physical processor

-XX: + UseParallelOldGC

Specifies OldGeneration use parallelcollector

-XX: + UseParNewGC

Specifies NewGeneration use parallelcollector, the GC is UseParallelGC upgraded version has better performance or merit, can be used together CMSGC

-XX: + CMSParallelRemarkEnabled

In the case of using UseParNewGC minimize mark time

-XX: + UseConcMarkSweepGC

Specifies OldGeneration use concurrentmarksweepGC, GCthread and Appthread parallel (in init-mark and remark when pauseappthread). apppause short time, a system for strong interaction, such as webserver

-XX: + UseCMSCompactAtFullCollection

In the case of using concurrentGC prevent memoryfragmention, to organize the liveobject that reduce memory fragmentation

Indicates oldgeneration n% in the use of the scale, the start concurrentcollector, the default value is 68, such as:-XX: CMSInitiatingOccupancyFraction = 70

-XX: + UseCMSInitiatingOccupancyOnly

Instructions in the use of only oldgeneration proportion initialization after concurrentcollector start collecting

3, others

Specify an object experiencing n times YoungGC and transferred to oldgeneration area, linux64 under the java6 default value is 15, this parameter is not valid for throughputcollector, such as:-XX: MaxTenuringThreshold = 31

-XX: + DisableExplicitGC

Prohibit java program FullGC, such as System. gc () call. Best to add code to prevent misuse of the program impact on performance.

-XX: + UseFastAccessorMethods

get, set method to native code switch

-XX: + PrintGCDetails

Should fight the case, such as garbage collection:

953935K (2070976K), 0.0196420secs]

-XX: + PrintGCTimeStamps

Playing time garbage collection should be the case, such as:

[Times: user = 0.09sys = 0.00, real = 0.02secs]

-XX: + PrintGCApplicationStoppedTime

Fight should refuse collection, the system pause time, such as: Totaltimeforwhichapplicationthreadswerestopped: 0.0225920seconds
Source: Network

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>