JVM tuning-Calculate active data size

Source: Internet
Author: User


active data, sometimes called survival data, refers to applications that are in a stable state of operation, Java the size of long-lived objects inside the heap. In other words, The amount of space (memory occupancy) that the Java heap takes up after FULLGC is applied in a state of steady operation.

1 , the importance of active data computing

Java The calculation of the applied active data size is what we do JVM an essential process of tuning, if we don't know how much of this system's active data, then how do we allocate the right memory for him? Therefore, calculating the active data size is an important step in JVM tuning.

Java the active data size of the app can be GC Log collection.

Active data mainly consists of two blocks, the size of the old age and the size of the permanent generation.

2 , how active data is viewed

In order to better calculate the active data size of the application, it is best to FULLGC java But then again, many JVM full GC

at the same time, some systems have been optimized, or met with good luck, casually set a parameter, the result is just good, FULLGC never happened before, such a situation, through GC Log collection is almost impossible to see Full GC occur. In this case, you can use some tools to force garbage collection and trigger the FULLGC event. For example , the JConsole triggered by the JDK 's own .

Calculating active data is my JVM the core of tuning.

First Look at a sample, in practical use to find Full GC it's easier, but the whole system is troublesome to move up, write a simple example, simulate FULLGC the situation that occurred.

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 = newbyte[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:48k->0k (4416K)][psoldgen:30879k->30879k (39488K)] 30927k->30879k (43904K) [Pspermgen : 2086k->2086k (12288K)], 0.0028453 secs] [times:user=0.00 sys=0.00, Real=0.00secs]

[GC [psyounggen:4098k->48k (4416K)] 34977k->35023k (43904K), 0.0035403 secs] [times:user=0.00 sys=0.00, real=0.00 secs]

[Full GC [psyounggen:48k->0k (4416K)] [psoldgen:34975k->34975k (44672K)]35023k->34975k (49088K) [Pspermgen: 2086k->2086k (12288K)], 0.0026413 secs][times:user=0.00 sys=0.00, real=0.00 secs]

[GC [psyounggen:4098k->48k (4416K)] 39073k->39119k (49088K), 0.0028593 secs] [times:user=0.00 sys=0.06, real=0.00 secs]

[GC [psyounggen:4146k->48k (4416K)] 43217k->43219k (49088K), 0.0035522 secs] [times:user=0.00 sys=0.00, real=0.00 secs]

[Full GC [psyounggen:48k->0k (4416K)] [psoldgen:43171k->43152k (54272K)]43219k->43152k (58688K) [Pspermgen: 2086k->2085k (12288K)], 0.0086702 secs][times:user=0.00 sys=0.00, real=0.01 secs]

[GC [psyounggen:4098k->64k (4416K)] 47250k->47312k (58688K), 0.0032439 secs] [times:user=0.00 sys=0.06, real=0.00 secs]

[GC [psyounggen:4162k->64k (4416K)] 51410k->51416k (58688K), 0.0049324 secs] [times:user=0.00 sys=0.00, real=0.00 secs]

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

...

5 , result analysis and active data size calculation

[Full GC [psyounggen:48k->0k (4416K)][psoldgen:43171k->43152k (54272K)] 43219k->43152k (58688K) [Pspermgen : 2086k->2085k (12288K)], 0.0086702 secs] [times:user=0.00 sys=0.00, Real=0.01secs]

[GC [psyounggen:4098k->64k (4416K)] 47250k->47312k (58688K), 0.0032439 secs] [times:user=0.00 sys=0.06, real=0.00 secs]

[GC [psyounggen:4162k->64k (4416K)] 51410k->51416k (58688K), 0.0049324 secs] [times:user=0.00 sys=0.00, real=0.00 secs]

[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]

As can be seen from here, the old age is slowly expanding.

[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]

after this data, basically stabilized, about the old age of space occupied is 51352K , the big size of the old is basically 56768K . The space occupied by the permanent band is 2085K, and the size is 12288K.

Therefore, the active data size of this program is: 51352k+ 2085K about equal to 55M

JVM tuning-Calculate active data size

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.