Newer
Older
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
.RE
.RE
.RE
.TP
.B \f[CB]\-XX:LogFile=\f[R]\f[I]path\f[R]
Sets the path and file name to where log data is written.
By default, the file is created in the current working directory, and
it\[aq]s named \f[CB]hotspot.log\f[R].
.RS
.IP \[bu] 2
\f[B]Linux and macOS:\f[R] The following example shows how to set the log
file to \f[CB]/var/log/java/hotspot.log\f[R]:
.RS 2
.RS
.PP
\f[CB]\-XX:LogFile=/var/log/java/hotspot.log\f[R]
.RE
.RE
.IP \[bu] 2
\f[B]Windows:\f[R] The following example shows how to set the log file to
\f[CB]C:/log/java/hotspot.log\f[R]:
.RS 2
.RS
.PP
\f[CB]\-XX:LogFile=C:/log/java/hotspot.log\f[R]
.RE
.RE
.RE
.TP
.B \f[CB]\-XX:+PrintClassHistogram\f[R]
Enables printing of a class instance histogram after one of the
following events:
.RS
.IP \[bu] 2
\f[B]Linux and macOS:\f[R] \f[CB]Control+Break\f[R]
.IP \[bu] 2
\f[B]Windows:\f[R] \f[CB]Control+C\f[R] (\f[CB]SIGTERM\f[R])
.PP
By default, this option is disabled.
.PP
Setting this option is equivalent to running the \f[CB]jmap\ \-histo\f[R]
command, or the \f[CB]jcmd\f[R] \f[I]pid\f[R] \f[CB]GC.class_histogram\f[R]
command, where \f[I]pid\f[R] is the current Java process identifier.
.RE
.TP
.B \f[CB]\-XX:+PrintConcurrentLocks\f[R]
Enables printing of \f[CB]java.util.concurrent\f[R] locks after one of the
following events:
.RS
.IP \[bu] 2
\f[B]Linux and macOS:\f[R] \f[CB]Control+Break\f[R]
.IP \[bu] 2
\f[B]Windows:\f[R] \f[CB]Control+C\f[R] (\f[CB]SIGTERM\f[R])
.PP
By default, this option is disabled.
.PP
Setting this option is equivalent to running the \f[CB]jstack\ \-l\f[R]
command or the \f[CB]jcmd\f[R] \f[I]pid\f[R] \f[CB]Thread.print\ \-l\f[R]
command, where \f[I]pid\f[R] is the current Java process identifier.
.RE
.TP
.B \f[CB]\-XX:+PrintFlagsRanges\f[R]
Prints the range specified and allows automatic testing of the values.
See \f[B]Validate Java Virtual Machine Flag Arguments\f[R].
.RS
.RE
.TP
.B \f[CB]\-XX:+PerfDataSaveToFile\f[R]
If enabled, saves \f[B]jstat\f[R] binary data when the Java application
exits.
This binary data is saved in a file named
\f[CB]hsperfdata_\f[R]\f[I]pid\f[R], where \f[I]pid\f[R] is the process
identifier of the Java application that you ran.
Use the \f[CB]jstat\f[R] command to display the performance data contained
in this file as follows:
.RS
.RS
.PP
\f[CB]jstat\ \-class\ file:///\f[R]\f[I]path\f[R]\f[CB]/hsperfdata_\f[R]\f[I]pid\f[R]
.RE
.RS
.PP
\f[CB]jstat\ \-gc\ file:///\f[R]\f[I]path\f[R]\f[CB]/hsperfdata_\f[R]\f[I]pid\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:+UsePerfData\f[R]
Enables the \f[CB]perfdata\f[R] feature.
This option is enabled by default to allow JVM monitoring and
performance testing.
Disabling it suppresses the creation of the \f[CB]hsperfdata_userid\f[R]
directories.
To disable the \f[CB]perfdata\f[R] feature, specify
\f[CB]\-XX:\-UsePerfData\f[R].
.RS
.RE
.SH ADVANCED GARBAGE COLLECTION OPTIONS FOR JAVA
.PP
These \f[CB]java\f[R] options control how garbage collection (GC) is
performed by the Java HotSpot VM.
.TP
.B \f[CB]\-XX:+AggressiveHeap\f[R]
Enables Java heap optimization.
This sets various parameters to be optimal for long\-running jobs with
intensive memory allocation, based on the configuration of the computer
(RAM and CPU).
By default, the option is disabled and the heap sizes are configured
less aggressively.
.RS
.RE
.TP
.B \f[CB]\-XX:+AlwaysPreTouch\f[R]
Requests the VM to touch every page on the Java heap after requesting it
from the operating system and before handing memory out to the
application.
By default, this option is disabled and all pages are committed as the
application uses the heap space.
.RS
.RE
.TP
.B \f[CB]\-XX:ConcGCThreads=\f[R]\f[I]threads\f[R]
Sets the number of threads used for concurrent GC.
Sets \f[I]\f[CI]threads\f[I]\f[R] to approximately 1/4 of the number of
parallel garbage collection threads.
The default value depends on the number of CPUs available to the JVM.
.RS
.PP
For example, to set the number of threads for concurrent GC to 2,
specify the following option:
.RS
.PP
\f[CB]\-XX:ConcGCThreads=2\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:+DisableExplicitGC\f[R]
Enables the option that disables processing of calls to the
\f[CB]System.gc()\f[R] method.
This option is disabled by default, meaning that calls to
\f[CB]System.gc()\f[R] are processed.
If processing of calls to \f[CB]System.gc()\f[R] is disabled, then the JVM
still performs GC when necessary.
.RS
.RE
.TP
.B \f[CB]\-XX:+ExplicitGCInvokesConcurrent\f[R]
Enables invoking of concurrent GC by using the \f[CB]System.gc()\f[R]
request.
This option is disabled by default and can be enabled only with the
\f[CB]\-XX:+UseG1GC\f[R] option.
.RS
.RE
.TP
.B \f[CB]\-XX:G1AdaptiveIHOPNumInitialSamples=\f[R]\f[I]number\f[R]
When \f[CB]\-XX:UseAdaptiveIHOP\f[R] is enabled, this option sets the
number of completed marking cycles used to gather samples until G1
adaptively determines the optimum value of
\f[CB]\-XX:InitiatingHeapOccupancyPercent\f[R].
Before, G1 uses the value of
\f[CB]\-XX:InitiatingHeapOccupancyPercent\f[R] directly for this purpose.
The default value is 3.
.RS
.RE
.TP
.B \f[CB]\-XX:G1HeapRegionSize=size\f[R]
Sets the size of the regions into which the Java heap is subdivided when
using the garbage\-first (G1) collector.
The value is a power of 2 and can range from 1 MB to 32 MB.
The default region size is determined ergonomically based on the heap
size with a goal of approximately 2048 regions.
.RS
.PP
The following example sets the size of the subdivisions to 16 MB:
.RS
.PP
\f[CB]\-XX:G1HeapRegionSize=16m\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:G1HeapWastePercent=\f[R]\f[I]percent\f[R]
Sets the percentage of heap that you\[aq]re willing to waste.
The Java HotSpot VM doesn\[aq]t initiate the mixed garbage collection
cycle when the reclaimable percentage is less than the heap waste
percentage.
The default is 5 percent.
.RS
.RE
.TP
.B \f[CB]\-XX:G1MaxNewSizePercent=\f[R]\f[I]percent\f[R]
Sets the percentage of the heap size to use as the maximum for the young
generation size.
The default value is 60 percent of your Java heap.
.RS
.PP
This is an experimental flag.
This setting replaces the \f[CB]\-XX:DefaultMaxNewGenPercent\f[R] setting.
.RE
.TP
.B \f[CB]\-XX:G1MixedGCCountTarget=\f[R]\f[I]number\f[R]
Sets the target number of mixed garbage collections after a marking
cycle to collect old regions with at most
\f[CB]G1MixedGCLIveThresholdPercent\f[R] live data.
The default is 8 mixed garbage collections.
The goal for mixed collections is to be within this target number.
.RS
.RE
.TP
.B \f[CB]\-XX:G1MixedGCLiveThresholdPercent=\f[R]\f[I]percent\f[R]
Sets the occupancy threshold for an old region to be included in a mixed
garbage collection cycle.
The default occupancy is 85 percent.
.RS
.PP
This is an experimental flag.
This setting replaces the
\f[CB]\-XX:G1OldCSetRegionLiveThresholdPercent\f[R] setting.
.RE
.TP
.B \f[CB]\-XX:G1NewSizePercent=\f[R]\f[I]percent\f[R]
Sets the percentage of the heap to use as the minimum for the young
generation size.
The default value is 5 percent of your Java heap.
.RS
.PP
This is an experimental flag.
This setting replaces the \f[CB]\-XX:DefaultMinNewGenPercent\f[R] setting.
.RE
.TP
.B \f[CB]\-XX:G1OldCSetRegionThresholdPercent=\f[R]\f[I]percent\f[R]
Sets an upper limit on the number of old regions to be collected during
a mixed garbage collection cycle.
The default is 10 percent of the Java heap.
.RS
.RE
.TP
.B \f[CB]\-XX:G1ReservePercent=\f[R]\f[I]percent\f[R]
Sets the percentage of the heap (0 to 50) that\[aq]s reserved as a false
ceiling to reduce the possibility of promotion failure for the G1
collector.
When you increase or decrease the percentage, ensure that you adjust the
total Java heap by the same amount.
By default, this option is set to 10%.
.RS
.PP
The following example sets the reserved heap to 20%:
.RS
.PP
\f[CB]\-XX:G1ReservePercent=20\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:+G1UseAdaptiveIHOP\f[R]
Controls adaptive calculation of the old generation occupancy to start
background work preparing for an old generation collection.
If enabled, G1 uses \f[CB]\-XX:InitiatingHeapOccupancyPercent\f[R] for the
first few times as specified by the value of
\f[CB]\-XX:G1AdaptiveIHOPNumInitialSamples\f[R], and after that adaptively
calculates a new optimum value for the initiating occupancy
automatically.
Otherwise, the old generation collection process always starts at the
old generation occupancy determined by
\f[CB]\-XX:InitiatingHeapOccupancyPercent\f[R].
.RS
.PP
The default is enabled.
.RE
.TP
.B \f[CB]\-XX:InitialHeapSize=\f[R]\f[I]size\f[R]
Sets the initial size (in bytes) of the memory allocation pool.
This value must be either 0, or a multiple of 1024 and greater than 1
MB.
Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes,
\f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, or \f[CB]g\f[R] or
\f[CB]G\f[R] to indicate gigabytes.
The default value is selected at run time based on the system
configuration.
.RS
.PP
The following examples show how to set the size of allocated memory to 6
MB using various units:
.IP
.nf
\f[CB]
\-XX:InitialHeapSize=6291456
\-XX:InitialHeapSize=6144k
\-XX:InitialHeapSize=6m
\f[R]
.fi
.PP
If you set this option to 0, then the initial size is set as the sum of
the sizes allocated for the old generation and the young generation.
The size of the heap for the young generation can be set using the
\f[CB]\-XX:NewSize\f[R] option.
.RE
.TP
.B \f[CB]\-XX:InitialRAMPercentage=\f[R]\f[I]percent\f[R]
Sets the initial amount of memory that the JVM will use for the Java
heap before applying ergonomics heuristics as a percentage of the
maximum amount determined as described in the \f[CB]\-XX:MaxRAM\f[R]
option.
The default value is 1.5625 percent.
.RS
.PP
The following example shows how to set the percentage of the initial
amount of memory used for the Java heap:
.RS
.PP
\f[CB]\-XX:InitialRAMPercentage=5\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:InitialSurvivorRatio=\f[R]\f[I]ratio\f[R]
Sets the initial survivor space ratio used by the throughput garbage
collector (which is enabled by the \f[CB]\-XX:+UseParallelGC\f[R] option).
Adaptive sizing is enabled by default with the throughput garbage
collector by using the \f[CB]\-XX:+UseParallelGC\f[R] option, and the
survivor space is resized according to the application behavior,
starting with the initial value.
If adaptive sizing is disabled (using the
\f[CB]\-XX:\-UseAdaptiveSizePolicy\f[R] option), then the
\f[CB]\-XX:SurvivorRatio\f[R] option should be used to set the size of the
survivor space for the entire execution of the application.
.RS
.PP
The following formula can be used to calculate the initial size of
survivor space (S) based on the size of the young generation (Y), and
the initial survivor space ratio (R):
.RS
.PP
\f[CB]S=Y/(R+2)\f[R]
.RE
.PP
The 2 in the equation denotes two survivor spaces.
The larger the value specified as the initial survivor space ratio, the
smaller the initial survivor space size.
.PP
By default, the initial survivor space ratio is set to 8.
If the default value for the young generation space size is used (2 MB),
then the initial size of the survivor space is 0.2 MB.
.PP
The following example shows how to set the initial survivor space ratio
to 4:
.RS
.PP
\f[CB]\-XX:InitialSurvivorRatio=4\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:InitiatingHeapOccupancyPercent=\f[R]\f[I]percent\f[R]
Sets the percentage of the old generation occupancy (0 to 100) at which
to start the first few concurrent marking cycles for the G1 garbage
collector.
.RS
.PP
By default, the initiating value is set to 45%.
A value of 0 implies nonstop concurrent GC cycles from the beginning
until G1 adaptively sets this value.
.PP
See also the \f[CB]\-XX:G1UseAdaptiveIHOP\f[R] and
\f[CB]\-XX:G1AdaptiveIHOPNumInitialSamples\f[R] options.
.PP
The following example shows how to set the initiating heap occupancy to
75%:
.RS
.PP
\f[CB]\-XX:InitiatingHeapOccupancyPercent=75\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:MaxGCPauseMillis=\f[R]\f[I]time\f[R]
Sets a target for the maximum GC pause time (in milliseconds).
This is a soft goal, and the JVM will make its best effort to achieve
it.
The specified value doesn\[aq]t adapt to your heap size.
By default, for G1 the maximum pause time target is 200 milliseconds.
The other generational collectors do not use a pause time goal by
default.
.RS
.PP
The following example shows how to set the maximum target pause time to
500 ms:
.RS
.PP
\f[CB]\-XX:MaxGCPauseMillis=500\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:MaxHeapSize=\f[R]\f[I]size\f[R]
Sets the maximum size (in byes) of the memory allocation pool.
This value must be a multiple of 1024 and greater than 2 MB.
Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes,
\f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, or \f[CB]g\f[R] or
\f[CB]G\f[R] to indicate gigabytes.
The default value is selected at run time based on the system
configuration.
For server deployments, the options \f[CB]\-XX:InitialHeapSize\f[R] and
\f[CB]\-XX:MaxHeapSize\f[R] are often set to the same value.
.RS
.PP
The following examples show how to set the maximum allowed size of
allocated memory to 80 MB using various units:
.IP
.nf
\f[CB]
\-XX:MaxHeapSize=83886080
\-XX:MaxHeapSize=81920k
\-XX:MaxHeapSize=80m
\f[R]
.fi
.PP
The \f[CB]\-XX:MaxHeapSize\f[R] option is equivalent to \f[CB]\-Xmx\f[R].
.RE
.TP
.B \f[CB]\-XX:MaxHeapFreeRatio=\f[R]\f[I]percent\f[R]
Sets the maximum allowed percentage of free heap space (0 to 100) after
a GC event.
If free heap space expands above this value, then the heap is shrunk.
By default, this value is set to 70%.
.RS
.PP
Minimize the Java heap size by lowering the values of the parameters
\f[CB]MaxHeapFreeRatio\f[R] (default value is 70%) and
\f[CB]MinHeapFreeRatio\f[R] (default value is 40%) with the command\-line
options \f[CB]\-XX:MaxHeapFreeRatio\f[R] and
\f[CB]\-XX:MinHeapFreeRatio\f[R].
Lowering \f[CB]MaxHeapFreeRatio\f[R] to as low as 10% and
\f[CB]MinHeapFreeRatio\f[R] to 5% has successfully reduced the heap size
without too much performance regression; however, results may vary
greatly depending on your application.
Try different values for these parameters until they\[aq]re as low as
possible yet still retain acceptable performance.
.RS
.PP
\f[CB]\-XX:MaxHeapFreeRatio=10\ \-XX:MinHeapFreeRatio=5\f[R]
.RE
.PP
Customers trying to keep the heap small should also add the option
\f[CB]\-XX:\-ShrinkHeapInSteps\f[R].
See \f[B]Performance Tuning Examples\f[R] for a description of using this
option to keep the Java heap small by reducing the dynamic footprint for
embedded applications.
.RE
.TP
.B \f[CB]\-XX:MaxMetaspaceSize=\f[R]\f[I]size\f[R]
Sets the maximum amount of native memory that can be allocated for class
metadata.
By default, the size isn\[aq]t limited.
The amount of metadata for an application depends on the application
itself, other running applications, and the amount of memory available
on the system.
.RS
.PP
The following example shows how to set the maximum class metadata size
to 256 MB:
.RS
.PP
\f[CB]\-XX:MaxMetaspaceSize=256m\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:MaxNewSize=\f[R]\f[I]size\f[R]
Sets the maximum size (in bytes) of the heap for the young generation
(nursery).
The default value is set ergonomically.
.RS
.RE
.TP
.B \f[CB]\-XX:MaxRAM=\f[R]\f[I]size\f[R]
Sets the maximum amount of memory that the JVM may use for the Java heap
before applying ergonomics heuristics.
The default value is the maximum amount of available memory to the JVM
process or 128 GB, whichever is lower.
.RS
.PP
The maximum amount of available memory to the JVM process is the minimum
of the machine\[aq]s physical memory and any constraints set by the
environment (e.g.
container).
.PP
Specifying this option disables automatic use of compressed oops if the
combined result of this and other options influencing the maximum amount
of memory is larger than the range of memory addressable by compressed
oops.
See \f[CB]\-XX:UseCompressedOops\f[R] for further information about
compressed oops.
.PP
The following example shows how to set the maximum amount of available
memory for sizing the Java heap to 2 GB:
.RS
.PP
\f[CB]\-XX:MaxRAM=2G\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:MaxRAMPercentage=\f[R]\f[I]percent\f[R]
Sets the maximum amount of memory that the JVM may use for the Java heap
before applying ergonomics heuristics as a percentage of the maximum
amount determined as described in the \f[CB]\-XX:MaxRAM\f[R] option.
The default value is 25 percent.
.RS
.PP
Specifying this option disables automatic use of compressed oops if the
combined result of this and other options influencing the maximum amount
of memory is larger than the range of memory addressable by compressed
oops.
See \f[CB]\-XX:UseCompressedOops\f[R] for further information about
compressed oops.
.PP
The following example shows how to set the percentage of the maximum
amount of memory used for the Java heap:
.RS
.PP
\f[CB]\-XX:MaxRAMPercentage=75\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:MinRAMPercentage=\f[R]\f[I]percent\f[R]
Sets the maximum amount of memory that the JVM may use for the Java heap
before applying ergonomics heuristics as a percentage of the maximum
amount determined as described in the \f[CB]\-XX:MaxRAM\f[R] option for
small heaps.
A small heap is a heap of approximately 125 MB.
The default value is 50 percent.
.RS
.PP
The following example shows how to set the percentage of the maximum
amount of memory used for the Java heap for small heaps:
.RS
.PP
\f[CB]\-XX:MinRAMPercentage=75\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:MaxTenuringThreshold=\f[R]\f[I]threshold\f[R]
Sets the maximum tenuring threshold for use in adaptive GC sizing.
The largest value is 15.
The default value is 15 for the parallel (throughput) collector.
.RS
.PP
The following example shows how to set the maximum tenuring threshold to
10:
.RS
.PP
\f[CB]\-XX:MaxTenuringThreshold=10\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:MetaspaceSize=\f[R]\f[I]size\f[R]
Sets the size of the allocated class metadata space that triggers a
garbage collection the first time it\[aq]s exceeded.
This threshold for a garbage collection is increased or decreased
depending on the amount of metadata used.
The default size depends on the platform.
.RS
.RE
.TP
.B \f[CB]\-XX:MinHeapFreeRatio=\f[R]\f[I]percent\f[R]
Sets the minimum allowed percentage of free heap space (0 to 100) after
a GC event.
If free heap space falls below this value, then the heap is expanded.
By default, this value is set to 40%.
.RS
.PP
Minimize Java heap size by lowering the values of the parameters
\f[CB]MaxHeapFreeRatio\f[R] (default value is 70%) and
\f[CB]MinHeapFreeRatio\f[R] (default value is 40%) with the command\-line
options \f[CB]\-XX:MaxHeapFreeRatio\f[R] and
\f[CB]\-XX:MinHeapFreeRatio\f[R].
Lowering \f[CB]MaxHeapFreeRatio\f[R] to as low as 10% and
\f[CB]MinHeapFreeRatio\f[R] to 5% has successfully reduced the heap size
without too much performance regression; however, results may vary
greatly depending on your application.
Try different values for these parameters until they\[aq]re as low as
possible, yet still retain acceptable performance.
.RS
.PP
\f[CB]\-XX:MaxHeapFreeRatio=10\ \-XX:MinHeapFreeRatio=5\f[R]
.RE
.PP
Customers trying to keep the heap small should also add the option
\f[CB]\-XX:\-ShrinkHeapInSteps\f[R].
See \f[B]Performance Tuning Examples\f[R] for a description of using this
option to keep the Java heap small by reducing the dynamic footprint for
embedded applications.
.RE
.TP
.B \f[CB]\-XX:MinHeapSize=\f[R]\f[I]size\f[R]
Sets the minimum size (in bytes) of the memory allocation pool.
This value must be either 0, or a multiple of 1024 and greater than 1
MB.
Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes,
\f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, or \f[CB]g\f[R] or
\f[CB]G\f[R] to indicate gigabytes.
The default value is selected at run time based on the system
configuration.
.RS
.PP
The following examples show how to set the mimimum size of allocated
memory to 6 MB using various units:
.IP
.nf
\f[CB]
\-XX:MinHeapSize=6291456
\-XX:MinHeapSize=6144k
\-XX:MinHeapSize=6m
\f[R]
.fi
.PP
If you set this option to 0, then the minimum size is set to the same
value as the initial size.
.RE
.TP
.B \f[CB]\-XX:NewRatio=\f[R]\f[I]ratio\f[R]
Sets the ratio between young and old generation sizes.
By default, this option is set to 2.
The following example shows how to set the young\-to\-old ratio to 1:
.RS
.RS
.PP
\f[CB]\-XX:NewRatio=1\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:NewSize=\f[R]\f[I]size\f[R]
Sets the initial size (in bytes) of the heap for the young generation
(nursery).
Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes,
\f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, or \f[CB]g\f[R] or
\f[CB]G\f[R] to indicate gigabytes.
.RS
.PP
The young generation region of the heap is used for new objects.
GC is performed in this region more often than in other regions.
If the size for the young generation is too low, then a large number of
minor GCs are performed.
If the size is too high, then only full GCs are performed, which can
take a long time to complete.
It is recommended that you keep the size for the young generation
greater than 25% and less than 50% of the overall heap size.
.PP
The following examples show how to set the initial size of the young
generation to 256 MB using various units:
.IP
.nf
\f[CB]
\-XX:NewSize=256m
\-XX:NewSize=262144k
\-XX:NewSize=268435456
\f[R]
.fi
.PP
The \f[CB]\-XX:NewSize\f[R] option is equivalent to \f[CB]\-Xmn\f[R].
.RE
.TP
.B \f[CB]\-XX:ParallelGCThreads=\f[R]\f[I]threads\f[R]
Sets the number of the stop\-the\-world (STW) worker threads.
The default value depends on the number of CPUs available to the JVM and
the garbage collector selected.
.RS
.PP
For example, to set the number of threads for G1 GC to 2, specify the
following option:
.RS
.PP
\f[CB]\-XX:ParallelGCThreads=2\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:+ParallelRefProcEnabled\f[R]
Enables parallel reference processing.
By default, this option is disabled.
.RS
.RE
.TP
.B \f[CB]\-XX:+PrintAdaptiveSizePolicy\f[R]
Enables printing of information about adaptive\-generation sizing.
By default, this option is disabled.
.RS
.RE
.TP
.B \f[CB]\-XX:+ScavengeBeforeFullGC\f[R]
Enables GC of the young generation before each full GC.
This option is enabled by default.
It is recommended that you \f[I]don\[aq]t\f[R] disable it, because
scavenging the young generation before a full GC can reduce the number
of objects reachable from the old generation space into the young
generation space.
To disable GC of the young generation before each full GC, specify the
option \f[CB]\-XX:\-ScavengeBeforeFullGC\f[R].
.RS
.RE
.TP
.B \f[CB]\-XX:SoftRefLRUPolicyMSPerMB=\f[R]\f[I]time\f[R]
Sets the amount of time (in milliseconds) a softly reachable object is
kept active on the heap after the last time it was referenced.
The default value is one second of lifetime per free megabyte in the
heap.
The \f[CB]\-XX:SoftRefLRUPolicyMSPerMB\f[R] option accepts integer values
representing milliseconds per one megabyte of the current heap size (for
Java HotSpot Client VM) or the maximum possible heap size (for Java
HotSpot Server VM).
This difference means that the Client VM tends to flush soft references
rather than grow the heap, whereas the Server VM tends to grow the heap
rather than flush soft references.
In the latter case, the value of the \f[CB]\-Xmx\f[R] option has a
significant effect on how quickly soft references are garbage collected.
.RS
.PP
The following example shows how to set the value to 2.5 seconds:
.PP
\f[CB]\-XX:SoftRefLRUPolicyMSPerMB=2500\f[R]
.RE
.TP
.B \f[CB]\-XX:\-ShrinkHeapInSteps\f[R]
Incrementally reduces the Java heap to the target size, specified by the
option \f[CB]\-XX:MaxHeapFreeRatio\f[R].
This option is enabled by default.
If disabled, then it immediately reduces the Java heap to the target
size instead of requiring multiple garbage collection cycles.
Disable this option if you want to minimize the Java heap size.
You will likely encounter performance degradation when this option is
disabled.
.RS
.PP
See \f[B]Performance Tuning Examples\f[R] for a description of using the
\f[CB]MaxHeapFreeRatio\f[R] option to keep the Java heap small by reducing
the dynamic footprint for embedded applications.
.RE
.TP
.B \f[CB]\-XX:StringDeduplicationAgeThreshold=\f[R]\f[I]threshold\f[R]
Identifies \f[CB]String\f[R] objects reaching the specified age that are
considered candidates for deduplication.
An object\[aq]s age is a measure of how many times it has survived
garbage collection.
This is sometimes referred to as tenuring.
.RS
.RS
.PP
\f[B]Note:\f[R] \f[CB]String\f[R] objects that are promoted to an old heap
region before this age has been reached are always considered candidates
for deduplication.
The default value for this option is \f[CB]3\f[R].
See the \f[CB]\-XX:+UseStringDeduplication\f[R] option.
.RE
.RE
.TP
.B \f[CB]\-XX:SurvivorRatio=\f[R]\f[I]ratio\f[R]
Sets the ratio between eden space size and survivor space size.
By default, this option is set to 8.
The following example shows how to set the eden/survivor space ratio to
4:
.RS
.RS
.PP
\f[CB]\-XX:SurvivorRatio=4\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:TargetSurvivorRatio=\f[R]\f[I]percent\f[R]
Sets the desired percentage of survivor space (0 to 100) used after
young garbage collection.
By default, this option is set to 50%.
.RS
.PP
The following example shows how to set the target survivor space ratio
to 30%:
.RS
.PP
\f[CB]\-XX:TargetSurvivorRatio=30\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:TLABSize=\f[R]\f[I]size\f[R]
Sets the initial size (in bytes) of a thread\-local allocation buffer
(TLAB).
Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes,
\f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, or \f[CB]g\f[R] or
\f[CB]G\f[R] to indicate gigabytes.
If this option is set to 0, then the JVM selects the initial size
automatically.
.RS
.PP
The following example shows how to set the initial TLAB size to 512 KB:
.RS
.PP
\f[CB]\-XX:TLABSize=512k\f[R]
.RE
.RE
.TP
.B \f[CB]\-XX:+UseAdaptiveSizePolicy\f[R]
Enables the use of adaptive generation sizing.
This option is enabled by default.
To disable adaptive generation sizing, specify
\f[CB]\-XX:\-UseAdaptiveSizePolicy\f[R] and set the size of the memory
allocation pool explicitly.
See the \f[CB]\-XX:SurvivorRatio\f[R] option.
.RS
.RE
.TP
.B \f[CB]\-XX:+UseG1GC\f[R]
Enables the use of the garbage\-first (G1) garbage collector.
It\[aq]s a server\-style garbage collector, targeted for multiprocessor
machines with a large amount of RAM.
This option meets GC pause time goals with high probability, while
maintaining good throughput.
The G1 collector is recommended for applications requiring large heaps
(sizes of around 6 GB or larger) with limited GC latency requirements (a
stable and predictable pause time below 0.5 seconds).
By default, this option is enabled and G1 is used as the default garbage
collector.
.RS
.RE
.TP
.B \f[CB]\-XX:+UseGCOverheadLimit\f[R]
Enables the use of a policy that limits the proportion of time spent by
the JVM on GC before an \f[CB]OutOfMemoryError\f[R] exception is thrown.
This option is enabled, by default, and the parallel GC will throw an
\f[CB]OutOfMemoryError\f[R] if more than 98% of the total time is spent on
garbage collection and less than 2% of the heap is recovered.
When the heap is small, this feature can be used to prevent applications
from running for long periods of time with little or no progress.
To disable this option, specify the option
\f[CB]\-XX:\-UseGCOverheadLimit\f[R].
.RS
.RE
.TP
.B \f[CB]\-XX:+UseNUMA\f[R]
Enables performance optimization of an application on a machine with
nonuniform memory architecture (NUMA) by increasing the
application\[aq]s use of lower latency memory.
By default, this option is disabled and no optimization for NUMA is
made.
The option is available only when the parallel garbage collector is used
(\f[CB]\-XX:+UseParallelGC\f[R]).
.RS
.RE
.TP
.B \f[CB]\-XX:+UseParallelGC\f[R]
Enables the use of the parallel scavenge garbage collector (also known
as the throughput collector) to improve the performance of your
application by leveraging multiple processors.
.RS
.PP
By default, this option is disabled and the default collector is used.
.RE
.TP
.B \f[CB]\-XX:+UseSerialGC\f[R]
Enables the use of the serial garbage collector.
This is generally the best choice for small and simple applications that
don\[aq]t require any special functionality from garbage collection.
By default, this option is disabled and the default collector is used.
.RS
.RE
.TP
.B \f[CB]\-XX:+UseSHM\f[R]
\f[B]Linux only:\f[R] Enables the JVM to use shared memory to set up
large pages.
.RS
.PP
See \f[B]Large Pages\f[R] for setting up large pages.
.RE
.TP
.B \f[CB]\-XX:+UseStringDeduplication\f[R]
Enables string deduplication.
By default, this option is disabled.
To use this option, you must enable the garbage\-first (G1) garbage
collector.
.RS
.PP
String deduplication reduces the memory footprint of \f[CB]String\f[R]
objects on the Java heap by taking advantage of the fact that many
\f[CB]String\f[R] objects are identical.
Instead of each \f[CB]String\f[R] object pointing to its own character
array, identical \f[CB]String\f[R] objects can point to and share the same
character array.
.RE
.TP
.B \f[CB]\-XX:+UseTLAB\f[R]
Enables the use of thread\-local allocation blocks (TLABs) in the young
generation space.
This option is enabled by default.
To disable the use of TLABs, specify the option \f[CB]\-XX:\-UseTLAB\f[R].
.RS
.RE
.TP
.B \f[CB]\-XX:+UseZGC\f[R]
Enables the use of the Z garbage collector (ZGC).
This is a low latency garbage collector, providing max pause times of a
few milliseconds, at some throughput cost.
Pause times are independent of what heap size is used.
Supports heap sizes from 8MB to 16TB.
.RS
.RE
.TP
.B \f[CB]\-XX:ZAllocationSpikeTolerance\f[R]=\f[I]factor\f[R]
Sets the allocation spike tolerance for ZGC.
By default, this option is set to 2.0.
This factor describes the level of allocation spikes to expect.
For example, using a factor of 3.0 means the current allocation rate can
be expected to triple at any time.
.RS
.RE
.TP
.B \f[CB]\-XX:ZCollectionInterval\f[R]=\f[I]seconds\f[R]
Sets the maximum interval (in seconds) between two GC cycles when using
ZGC.
By default, this option is set to 0 (disabled).
.RS
.RE
.TP
.B \f[CB]\-XX:ZFragmentationLimit\f[R]=\f[I]percent\f[R]
Sets the maximum acceptable heap fragmentation (in percent) for ZGC.
By default, this option is set to 25.
Using a lower value will cause the heap to be compacted more
aggressively, to reclaim more memory at the cost of using more CPU time.
.RS
.RE
.TP
.B \f[CB]\-XX:+ZProactive\f[R]
Enables proactive GC cycles when using ZGC.
By default, this option is enabled.
ZGC will start a proactive GC cycle if doing so is expected to have
minimal impact on the running application.
This is useful if the application is mostly idle or allocates very few
objects, but you still want to keep the heap size down and allow
reference processing to happen even when there are a lot of free space
on the heap.
.RS
.RE
.TP
.B \f[CB]\-XX:+ZUncommit\f[R]
Enables uncommitting of unused heap memory when using ZGC.
By default, this option is enabled.
Uncommitting unused heap memory will lower the memory footprint of the
JVM, and make that memory available for other processes to use.
.RS
.RE
.TP
.B \f[CB]\-XX:ZUncommitDelay\f[R]=\f[I]seconds\f[R]
Sets the amount of time (in seconds) that heap memory must have been
unused before being uncommitted.
By default, this option is set to 300 (5 minutes).
Committing and uncommitting memory are relatively expensive operations.
Using a lower value will cause heap memory to be uncommitted earlier, at
the risk of soon having to commit it again.
.RS
.RE
.SH DEPRECATED JAVA OPTIONS
.PP
These \f[CB]java\f[R] options are deprecated and might be removed in a
future JDK release.
They\[aq]re still accepted and acted upon, but a warning is issued when
they\[aq]re used.
.TP
.B \f[CB]\-Xfuture\f[R]
Enables strict class\-file format checks that enforce close conformance
to the class\-file format specification.
Developers should use this flag when developing new code.
Stricter checks may become the default in future releases.
.RS
.RE
.TP
.B \f[CB]\-Xloggc:\f[R]\f[I]filename\f[R]
Sets the file to which verbose GC events information should be
redirected for logging.
The \f[CB]\-Xloggc\f[R] option overrides \f[CB]\-verbose:gc\f[R] if both are
given with the same java command.
\f[CB]\-Xloggc:\f[R]\f[I]filename\f[R] is replaced by
\f[CB]\-Xlog:gc:\f[R]\f[I]filename\f[R].
See Enable Logging with the JVM Unified Logging Framework.
.RS
.PP
Example:
.PP
\f[CB]\-Xlog:gc:garbage\-collection.log\f[R]
.RE
.TP
.B \f[CB]\-XX:+FlightRecorder\f[R]
Enables the use of Java Flight Recorder (JFR) during the runtime of the
application.
Since JDK 8u40 this option has not been required to use JFR.
.RS
.RE
.TP
.B \f[CB]\-XX:InitialRAMFraction=\f[R]\f[I]ratio\f[R]
Sets the initial amount of memory that the JVM may use for the Java heap
before applying ergonomics heuristics as a ratio of the maximum amount
determined as described in the \f[CB]\-XX:MaxRAM\f[R] option.
The default value is 64.
.RS
.PP
Use the option \f[CB]\-XX:InitialRAMPercentage\f[R] instead.
.RE
.TP
.B \f[CB]\-XX:MaxRAMFraction=\f[R]\f[I]ratio\f[R]
Sets the maximum amount of memory that the JVM may use for the Java heap
before applying ergonomics heuristics as a fraction of the maximum
amount determined as described in the \f[CB]\-XX:MaxRAM\f[R] option.
The default value is 4.
.RS