Skip to content

-XX:[+|-]UseGCStartupHints

When this option is enabled, the VM calculates, over several application restarts, an appropriate startup heap size for your application. You can therefore use this option instead of calculating and setting an -Xms value yourself. Setting an initial size for the heap that is larger than the default helps to avoid frequent garbage collections during the startup phase of an application.

Syntax

    -XX:[+|-]UseGCStartupHints
Setting Effect Default
-XX:+UseGCStartupHints Enable yes
-XX:-UseGCStartupHints Disable

When enabled, the VM records the heap size when a startup complete event occurs, storing the value into the shared classes cache. On subsequent restarts, the garbage collector (GC) reads this value early in startup processing and expands the heap to an appropriate value. For accuracy and stability, averages are taken over a few restarts to stabilize the value used. The heap size recorded is specific to the application command line, therefore a different hint is stored for every unique command line.

You can check the value used by the garbage collector for heap expansion by inspecting verbose GC output. The following example shows heap expansion based on hints from the previous run when using the gencon policy:

<heap-resize id="2" type="expand" space="nursery" amount="205258752" count="1" timems="0.328" reason="hint from previous runs" timestamp="2019-06-05T13:26:32.021" />
<heap-resize id="3" type="expand" space="tenure" amount="692649984" count="1" timems="0.326" reason="hint from previous runs" timestamp="2019-06-05T13:26:32.022" />

The final value stored to the shared cache is not recorded in the verbose GC output.

Notes:

  • When enabled, this option overrides any initial heap size that is specified on the command line, for example by using the -Xms option.
  • Because the shared classes cache is used to store heap size information, this option does not work if class data sharing (-Xshareclasses) is disabled.

Restriction: This feature is not currently available with the Balanced GC policy.