-
Book Overview & Buying
-
Table Of Contents
Java Memory Management
By :
One of the major changes from PermGen (pre-Java 8) to Metaspace (Java 8 onwards) is that the Metaspace can now grow in size. By default, the amount of memory allocated for the Metaspace is unbounded, as it is part of native memory. The size of the Metaspace can be customized using the JVM –XX:MetaspaceSize flag.
The Metaspace can trigger garbage collection in only two scenarios:
Let us examine these in turn.
As stated, by default, the native memory available to the Metaspace is unlimited. If you run out of memory, you get an OutOfMemoryError message, and this will trigger a run of the garbage collector. You can limit the Metaspace size with the JVM –XX:MaxMetaspaceSize flag. If you reach this limit, that will also trigger a run of the garbage collector.
We can configure...