Skip to content

-Xcompactgc / -Xnocompactgc

Enables or disables full compaction on system and global garbage collection (GC) activities.


Setting Action
-Xcompactgc Enable full compaction
-Xnocompactgc Disable full compaction

Default behavior

If a compaction option is not specified, the garbage collector compacts based on a series of triggers. These triggers attempt to compact only when it is beneficial to the future performance of the VM.

These options are not applicable to the following GC policies:

  • balanced GC policy (-Xgcpolicy:balanced): compaction is always enabled.
  • metronome GC policy (-Xgcpolicy:metronome): compaction is not supported.

See also