Java Virtual Machine heap management | Heap shrinkage


17.5.1 Heap expansion

Heap expansion occurs after garbage collection while exclusive access of the virtual machine is still held. The active part of the heap is expanded up to the maximum if one of the following is true:

The amount to expand the heap is calculated as follows:

If this is greater than the maximum expansion amount, which you can set with the -Xmaxe parameter (default of 0, which means no maximum expansion), the calculation is reduced to -Xmaxe.

If this is less than the minimum expansion amount, which you can set with the -Xmine parameter (default of 1 MB), it is increased to -Xmine.

All calculated expansion amounts are rounded up to a 256-byte boundary (512 bytes if concurrent mark is used) on 32-bit architecture, or a 1024 byte boundary on 64-bit architecture.