Java Reference
In-Depth Information
bigger applications will need bigger areas. One of the advantages to phasing out permgen is
that the metaspace rarely needs to be sized—because (unlike permgen) metaspace will by de-
fault use as much space as it needs. Table 5-5 lists the default initial and maximum sizes for
permgen and metaspace.
Table 5-5. Default sizes of permgen/metaspace
Default initial
Default maximum permgen
Default maximum metaspace
32-bit client
12 MB
64 MB
32-bit server
16 MB
64 MB
64-bit JVM
20.75 MB
82 MB
These memory regions behave just like a separate instance of the regular heap. They are
sized dynamically based on an initial size and will increase as needed to a maximum size.
For permgen, the sizes are specified via these flags: -XX:PermSize= N and -
XX:MaxPermSize= N . Metaspace is sized with these flags: -XX:MetaspaceSize= N and -
XX:MaxMetaspaceSize= N .
Because the default size of metaspace is unlimited, there is the possibility (particularly in a 32-bit
JVM) that a Java 8 application can run out of memory by filling up metaspace. The Native
Memory Tracking (NMT) tools discussed in Chapter 8 can help diagnose that case. If metaspace
is growing too big, you can set the value of MaxMetaspaceSize lower—but then the application
will eventually get an OutOfMemoryError when the metaspace fills up. Figuring out why the
class metadata is too large is the real remedy in that case.
Resizing these regions requires a full GC, so it is an expensive operation. If there are a lot of
full GCs during the startup of a program (as it is loading classes), it is often because permgen
or metaspace is being resized, so increasing the initial size is a good idea to improve startup
in that case. Java 7 applications that define a lot of classes should increase the maximum size
Search WWH ::

Custom Search