爱国者
爱国者

Reputation: 4328

Why MaxNewSize is larger than MaxHeapSize in JVM?

enter image description here

I only setup some of JVM configuration on startup: -Xmx1024m -Xms1024m -XX:MaxPermSize=128m -XX:PermSize=128m

Upvotes: 1

Views: 3068

Answers (2)

apangin
apangin

Reputation: 98284

From HotSpot sources:

product(uintx, MaxNewSize, max_uintx,                                     \
        "Maximum new generation size (in bytes), max_uintx means set "    \
        "ergonomically")                                                  \

Since you haven't set MaxNewSize explicitly, the default value is taken which is treated specially.
Anyway, MaxNewSize value is only a hint, while NewSize holds the real size of young generation.

Upvotes: 1

Brad Schoening
Brad Schoening

Reputation: 1371

The size of the young generation to the old generation is controlled by NewRatio. So, even though MaxNewSize > MaxHeapSize, with NewRatio=2, the effective max size of new space is 1:2. The old generation occupies 2/3 of the heap while the new generation occupies 1/3.

In your case, that is 2/3* 1024 = 682.6M for old space and 1/3 * 1024 = 341M for new space.

The threshold for MaxNewSize would only kick in if it was lower than that provided with NewRatio. Think of these as multiple, independent knobs with which to configure memory. The JVM will choose a setting conforming with all settings.

Upvotes: 0

Related Questions