Sun Hotspot 1.4.1 Adjustment of JVM Heap Size

xiaoxiao2021-03-05  27

Sun Hotspot 1.4.1

Using a genetic collector, it divides the heap into three main domains: new domain, old domain, and permanent domain.

JVM

All new objects generated are placed in a new domain. Once the object has experienced a certain number of garbage collection cycles, the use period is obtained and enters the old domain. In the permanent domain

JVM

Store

Class

with

Method

Object. In terms of configuration, the permanent domain is a separate domain and is not considered part of the stack. The following describes how to control the size of these domains.

be usable

-XMS

with

-Xmx

Control the original size or maximum of the entire heap. For example, the following command sets the initial size to

128M

:

Java -XMS

128M

-Xmx

256M

To control the size of the new domain, you can use

-Xx: Newratio

Set the proportion of the new domain in the heap. For example, the following command sets the entire heap to

128M

, New domain ratio set

3

That is, the proportion of the new domain and the old domain is

1

:

3

, The new field is a heap

1/4

or

32M

:

Java -XMS

128M

-Xmx

128M

-Xx: newratio = 3

be usable

-Xx: Newsize

with

-Xx: MaxNewsize

Set the initial value and maximum of the new domain. For example, the following command sets the initial value and maximum value of the new domain to

64M

: Java -xms

256M

-Xmx

256M

-Xmn

64M

The permanent domain is generally not part of the pile. Permanent domain default size

4M

. When running the program,

JVM

The size of the permanent domain will be adjusted to meet the needs. Each time you adjust,

JVM

A complete garbage collection will be made to the heap. use

-Xx: maxPersize

Sign to increase the permanent domain. in

WebLogic Server

When the application loads more categories, the maximum value of the permanent domain often needs to be increased. when

JVM

When loading a class, the object in the permanent domain has increased sharply, thus

JVM

Continuously adjust the permanent domain size. To avoid adjustment, you can use

-Xx: Persize

The logo sets the initial value. For example, the permanent domain initial value is set to

32M

And the maximum is set to

64M

.

Java -XMS

512M

-Xmx

512M

-Xmn

128M

-Xx: permsize =

32M

-Xx: maxpermsize =

64M

By default,

Hotspot

Use a replication collector in a new domain. This domain is generally divided into three parts. The first part is

Eden

Used to generate new objects. The other two is called the rescue space, when

Eden

When full, the collector stops the application and copy all the reachable objects to the current

From

Help space, once the current

From

The rescue space is full, the collector copies the reachable object to the current

TO

Help space.

From

with

TO

Help spatial interchange role. Maintaining activities will continue to replicate in the rescue space until they get in use and transfer to the old domain.

use

-Xx: Survivorratio

The size of the new domain subspace can be controlled. with

NEWRATION

same,

Survivorration

Specify a rescue domain and

Eden

The ratio of space. For example, the following command sets the new domain to

64M

,

Eden

Take up

32M

Each rescue domain accounted for

16m

:

Java -XMS

256M

-Xmx

256M

-Xmn

64M

-Xx: survivorration = 2

As mentioned earlier, by default

Hotspot

Use the replication collector for the new domain to use the tag-clear-compressed collector for the old domain. There is a lot of significance to use the replication collector in the new domain because the application is generated - Bidi-Language: Ar-Sa; MSO-ASCII-FONT-FAMILY: 'TIMES New Roman'; MSO-HANSI-FONT- Family: 'Times New Roman'; MSO-BIDI-FONT-FAMILY: 'TIMES New Roman' "> The object of the space is long life, then theoretically moves them into the old domain to avoid repeated replication in the rescue space. However, the application cannot suit this ideal because they have a small part of the longest life. It is best to keep these long life objects and placed in a new domain, because copying small parts of objects total ratio compressed old domain cheap.

To control the copy of the object in the new domain, available

-Xx: Targetsurvivorratio

Control the proportion of rescue space. This value is a percentage, the default value is

50

. When a larger stack is low

Sruvivorratio

When it should be added to

80

to

90

To make better use of rescue space.

use

-Xx: maxtenuring threshold

Controlled upper. All of the replication occurred and hope objects

Eden

Extended to the old domain, you can

Maxtenuring threshold

Set

0

. After the setting is complete, it is actually no longer used the rescue space, so it should be

Survivorratio

Set to maximum to maximize

Eden

Space, set as follows:

Java ... -xx: maxtenuringthreshold = 0 -xx: Survivorratio

=

5000 ...

Here is how to

JVM

Get information in the adjustment scheme.

-verbose.gc

Switch can be displayed

GC

Operation content. Open it, you can display the time that the most busy and the most idle collection behavior occurs, collect the memory size before and after collecting, collecting the time required.

turn on

-xx: printgcdetails

Switch, you can learn more

GC

Changes in.

turn on

-Xx: printgctimestamps

Switch, you can understand the time of these garbage collection,

JVM

Mel then the startup.

Finally, through

-xx: Printheapatgc

Switch understands more detailed information on the heap.

In order to understand the situation in the new field, you can pass

-Xx: = PrinttenUringDistribution

Switch understands the object of the use period.

转载请注明原文地址:https://www.9cbs.com/read-33232.html

New Post(0)