JVM Tuning-Initialize the size of the space configuration

Source: Internet
Author: User

We get the active data size and we can configure our initialization space based on the active data.

here is a section of our application in the stabilization phase FULLGC . The generated code is at the end.

1 , active data Examples

[Full gc[psyounggen:64k->0k (4416K)] [psoldgen:51352k->51352k (56768K)]51416k->51352k (61184K) [Pspermgen: 2085k->2085k (12288K)], 0.0026228 secs][times:user=0.00 sys=0.00, real=0.00 secs]

Psyounggen : Cenozoic Situation

Psoldgen : The old age situation, occupy space 51352K , 51M , this is an active data situation in the old age.

Pspermgen : Permanent belt condition, space occupied 2085K , 2M , it is a permanent band of active data size.

2 , common experience parameters

2.1 old age Size

   Java The initialization and maximum values of the heap size (via -xms Span style= "Color:rgb (51,51,51)" >-xmx option to specify) should be the size of the old age of the active object 3 to 4

The above GC record shows that the old age size is 51M, then the corresponding initial and maximum values are at 153M to 204M between; -xms153m–xmx204m

2.2 Permanent Generation size

         Another rule is that the initial and maximum values of the permanent band (-xx:permsizeand the-xx:maxpermsize) should be permanent with the active object size1.2to the1.5times. In the aboveFULLGCafter that, the permanent occupancy space is2M. Therefore, the recommended size for a permanent generation is2.4Mto the3M,that can be set to-xx:permsize=3m-xx:maxpermsize=3m (1.5Times).

2.3 Cenozoic Size

The Cenozoic space should be 1 to 1.5 times the size of the active object in the old age . So in this example, the Cenozoic size can be set to 51M to 76M.

So the final parameter is:-xms200m-xmx200m-xmn60m-xx:permsize=3m-xx:maxpermsize=3m-xx:+useparallelgc-xx : +printgcdetails

After use,thefullgc is no longer present, and there is no memory overflow problem.

3 , calculate active data (simulate Full GC ) 's Source code

PACKAGECOM.GC;

Importjava.util.ArrayList;

Importjava.util.List;

/**

 * a simple simulation FULLGC To calculate the active data size

 * Parameters: -xms30m-xmx60m-xx:+useparallelgc-xx:+printgcdetails

* @author Fan Fangming

*/

Publicclass Easyactivedata {

Public byte[] PlaceHolder = new byte[1024* [1024x768]; placeholder 1M

public static void Main (string[] args) throws exception{

ActiveData ();

}

private static void ActiveData () throwsexception{

List<easyactivedata>list_a = new arraylist<easyactivedata> ();

List<easyactivedata>list_b = new arraylist<easyactivedata> ();

for (int j=0; J < 25;j + +) {

easyactivedataserial = new Easyactivedata ();

List_a.add (serial);

}

Thread.Sleep (+);// Pause under

for (int j=0; J < 30;j + +) {

easyactivedataserial = new Easyactivedata ();

List_b.add (serial);

}

Thread.Sleep (+);// Pause under

while (true) {

easyactivedataserial = new Easyactivedata ();

serial = List_a.get (0);

serial = NULL;

Serial =list_b.get (0);;

Thread.Sleep (+);// Pause Ten milliseconds

}

}

}

Operating parameters

-xms30m Boot Memory

-xmx60m Maximum Memory

-XX:+USEPARALLELGC Choice of garbage collection method

-xx:+printgcdetails Print GC Detail

4 , running results

...

[Full GC [psyounggen:64k->0k (4416K)] [psoldgen:51352k->51352k (56768K)]51416k->51352k (61184K) [Pspermgen: 2085k->2085k (12288K)], 0.0026228 secs][times:user=0.00 sys=0.00, real=0.00 secs]

[GC [psyounggen:4098k->48k (4416K)] 55450k->55496k (61184K), 0.0038392 secs] [times:user=0.00 sys=0.00, real=0.00 secs]

[Full GC [psyounggen:48k->0k (4416K)] [psoldgen:55448k->55448k (56768K)]55496k->55448k (61184K) [Pspermgen: 2085k->2085k (12288K)], 0.0025522 secs][times:user=0.02 sys=0.00, real=0.00 secs]

[Full GC [psyounggen:4098k->0k (4416K)] [psoldgen:55448k->56472k (56768K)]59546k->56472k (61184K) [Pspermgen : 2085k->2085k (12288K)], 0.0043092 secs]

...

JVM Tuning-Initialize the size of the space configuration

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.