We throw an OOM in metaspace in two cases:
- when hitting CompressedClassSpaceSize (compressed-class-space-local reserve limit)
- when hitting MaxMetaspaceSize (global commit limit)
Text says "Out of Metaspace" resp. "Out of Compressed Class Space", depending on whether the allocation hitting the limit was from class space or not.
This is imprecise on multiple levels.
The exception text is a bit misleading: naive interpretation would be "we hit the allocation limit for either class space or non-class space". But this is not what is currently implemented, nor can it be implemented, since non-class space has no limit (MaxMetaspaceSize is a global limit and limits compressed class space too).
We could change the behaviour such that the OOM text depends on which limit we did hit (regardless of the data type of the allocation). That would make more sense. But probably we should change the exception text too then, clearly stating the limit we hit.
Alternatively we could just keep the exception text more vague.
(This should be done after JEP387 hits mainline.)