Semantics of `-Xmn`
Thomas Schatzl
thomas.schatzl at oracle.com
Wed Dec 7 08:20:22 UTC 2022
Hi,
On 07.12.22 08:38, Stefan Johansson wrote:
> Hi Ramki,
>
> On 2022-12-06 14:47, Stefan Karlsson wrote:
>> On 2022-12-04 03:38, Ramakrishna, Ramki wrote:
>>> Question: Can `-Xmn` be interpreted as "fix young gen size to the
>>> specified value, not allowing any resizing"?
>>>
>
> Kind of, but not exactly for G1. With G1 setting `-Xmn` will create a
> policy that doesn't recalculate the desired size of the young generation
> and sets it to the given value. But this is just a "desired" size and it
> doesn't set a fixed size for the old generation. So if the application
> keeps a lot of objects alive the old generation might grow "too large"
> and cause the young generation to be smaller than what is set with `-Xmn`.
> > Same goes for `-XX:NewSize` in G1 it will not be a hard minimum but set
> the desired minimum to this value.
+1
G1's policy in this situation is fairly crude: it by default tries to
keep this free region reserve (G1ReservePercent) to accommodate
surviving objects in the next gc.
Since this is a static measure, this is fairly prone to being wrong in
either direction, either too large (for large heaps) or too small (for
small heaps), in the best case using a smaller than expected young gen
(degrading "nicely") or in the worst case running into Full GCs.
Not much effort has been put into better behavior in this situation.
Thanks,
Thomas
More information about the hotspot-gc-dev
mailing list