7.9 Estimating the memory size of the Metaspace area in Java heap
This section explains how to estimate the memory size of the Metaspace area when using serial GC. The Metaspace area stores loaded classes and other objects.
As mentioned in 7.2.6 Configuration of memory space used by JavaVM when using serial GC and JavaVM options, the memory size of the Metaspace area is allocated separately from the memory size specified by the -Xmx option (Java heap).
For details about the default values, see 14.4 Default values of the Java HotSpot VM options that can be specified in Cosminexus in the uCosminexus Application Server Definition Reference Guide.
The method for estimating the usage of the Metaspace area is as follows:
-
Method of estimating the usage of the Metaspace area
The memory usage in the Metaspace area is almost the total size of the class files loaded in the J2EE server. In case of Application Server, you can perform estimations on the basis of the sum of following class file size:
-
All the class files under WEB-INF/classes
-
All the class files included in the JAR files under WEB-INF/lib
-
All the class files generated as a result of JSP compilation
-
All the class files included in EJB-JAR
-
If container extension library, library JAR, and reference library are being used, then all the class files included in the JAR files that are added
-
Class files loaded by containers
Metaspace-area-after-application-starts - Metaspace-area-before-application-is-registered. Calculate this value by actually running the J2EE server and then checking the Metaspace area.
-
Class files provided by the Application Server (system class files)
The total size of the system class files is approximately 140 MB.
-
Class files provided by JDK
The total size of the class files provided by JDK is approximately 110 MB.
-
Dynamic class generated by reflection processing
Reflection processing dynamically generates calling classes to increase processing speed.
Determine the size of this class by measuring how much the size of the Metaspace area increases after the server has been running for a reasonable period of time.
Specify the memory size of the Metaspace area in the -XX:MaxMetaspaceSize=size and -XX:MetaspaceSize=size options. For details about the default values of these options, see 14.4 Default values of the Java HotSpot VM options that can be specified in Cosminexus in the uCosminexus Application Server Definition Reference Guide.
Note that the usage of the Metaspace area might temporarily increase while importing the application.
- Reference note
-
Resolution method when the Metaspace area is compressed due to software references in the development environment
Due to software references, the release of the Metaspace area might be delayed when an application is un-deployed. Therefore, when you repeatedly deploy and un-deploy applications in the development environment, the Metaspace area might be compressed due to the delay in the release of the Metaspace area. Specify the following option to resolve the compression of the Metaspace area due to software references:
-
-XX:SoftRefLRUPolicyMSPerMB=0
If you specify 0 in the -XX:SoftRefLRUPolicyMSPerMB option, all software references are disabled. A software reference is often used as a cache for performance improvement, so the performance of an application might deteriorate due to the specification of this option. Therefore, specify this option only when the Metaspace area is compressed in the development environment.
-
-