Review request (S) JDK-8004241 NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option

Jon Masamitsu jon.masamitsu at
Thu Mar 7 12:57:30 PST 2013

On 03/07/13 00:54, Mikael Gerdin wrote:
> Hi
> When deciding when to reserve more metaspace memory we erroneously 
> looked only at the "capacity" of the metaspace insted of the reserved 
> space (which is what we ask this function when expanding).

Using MetaspaceAux::reserved_in_bytes() means that we
could return false here

1105   if (!FLAG_IS_DEFAULT(MaxMetaspaceSize)&&
1106       MetaspaceAux::reserved_in_bytes()>= MaxMetaspaceSize) {
1107     return false;
1108   }

when most of the space reserved in one or two  VirtualSpace's is unused.
With the current value of parameters, that could almost be 512kb.


> Additionally, we didn't check MaxMetaspaceSize against the sum of 
> reserved(Class) + reserved(NonClass) which caused us to use more than 
> MaxMetaspaceSize even when it was set.
> Bug:
> (not yet available at the time of writing this mail)
> Webrev:
> Testing:
> JPRT with -XX:MaxMetaspaceSize set for all tests to exercise the code 
> path.

More information about the hotspot-gc-dev mailing list