07JVM parameter tuning -05 concluded

JVM parameter tuning summary

    In the JVM startup parameters, you can set some parameters with memory, garbage collection related to the default settings JVM will not do any good work, but for some good Server configuration and specific application must be carefully tuned to get optimal performance. We hope to achieve by setting some goals:

  • GC time is small enough
  • GC sufficient number of less
  • It occurred Full GC ( new Mesozoic and the old year cycle) long enough

  The first two are currently contrary, in order to GC time must be a little smaller heap, GC to ensure sufficient number of small, we must ensure that a larger heap, we can only choose the balance.

   ( 1) is provided for the JVM stack, generally defined by -Xms -Xmx its minimum, maximum, in order to prevent shrinkage heap garbage collector between a minimum, a maximum additional time is generated, we usually the maximum, minimum set the same value ( 2) and the young generation to the old generation in accordance with a default ratio: heap memory is allocated (12), can be adjusted by adjusting the size ratio between the two NewRadio between them, can also be recovered for substituting such as the young generation, by -XX: to set its absolute size MaxNewSize: newSize -XX. Similarly, in order to prevent the contraction of the young generation of the heap, we will usually -XX: newSize -XX: MaxNewSize set to the same size
   

   ( 3) the young generation and the old generation set how much is reasonable? I have no doubt this question is unanswered, otherwise there would be no tuning. What we look at the impact of changes in the size of both

    • Bigger the young generation will inevitably lead to a smaller tenured generation, large young generation will extend the ordinary GC cycle, but will increase each time the GC; small older generation will lead to more frequent Full GC
    • Smaller younger generations will inevitably lead to more old generation, the young generation will lead to a small common GC very often, but every time the GC time will be shorter; large elderly generation will reduce the frequency of Full GC
    • How to choose should depend on the distribution of the application object lifecycle: If the application there are a lot of temporary objects, you should choose bigger the young generation; if there is a relatively large number of persistent objects, old generation should be appropriately increased. But many applications do not have such distinct characteristics, in the choice should be based on the following two points :( the principle of the Full GC as little as possible of A), so that the old generation as much as possible common object caching, JVM default scale of 1: 2 is the truth (B) by observing the period of application, see other at the peak of the old generation will account for how much memory, without affecting Full GC, increase the young generation of the actual situation, for example, can be controlled in proportion of 1: 1. But to the old generation should leave at least 1/3 of room for growth

Guess you like

Origin www.cnblogs.com/gcq243627152qq/p/12014338.html