When using OpenJDK Image on OpenShift/Kubernetes, the default maximum value for the Metaspace is XX:MaxMetaspaceSize=100m. OutOfMemoryError: Metaspace on OpenShift/Kubernetes This can be a precious hint to determine if a Classloader is loading an increasing number of classes. Other interesting options include the parameter -gcutil: $ jstat -gcutil (PID) | awk ''), 'lhs.count < rhs.count'), 'toHtml(it) + " If MaxMetaspaceSize is set smaller than CompressedClassSpaceSize, the JVM auto adjusts CompressedClassSpaceSize using this formula: CompressedClassSpaceSize = MaxMetaspaceSize - 2 * InitialBootClassLoaderMetaspaceSize ![]() Therefore, MaxMetaspaceSize should be larger than CompressedClassSpaceSize. The CompressedClassSpaceSize is the amount of virtual memory reserved for compressing Class MetaData. YGC: Number of young generation GC events.īesides the Metaspace capacity, pay attention to the Compressed class space maximum capacity.CCSMX: Compressed class space maximum capacity (kB).CCSMN: Compressed class space minimum capacity (kB).When used with the option -gcmetacapacity it provides the following information: jstat -gcmetacapacity (PID)įor example: MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC FGCT CGC CGCTĠ.0 374784.0 140360.0 0.0 253952.0 21168.0 23 0 0.000 6 0.046 The simplest way to monitor the MetaSpace size is by means of the jstat tool which is available in the JDK. When the space committed for class Metadata reaches a certain threshold (a high-water mark), a Garbage Collection happens.Īfter the Garbage Collection, the high-water mark may change depending on the amount of space freed from class Metadata. Java classes are unloaded as a result of Garbage collection, and garbage collections may be triggered in order to unload classes and deallocate class Metadata. A class loader allocates space for Metadata from its chunks.Ĭlass Metadata is deallocated when the corresponding Java class is unloaded and its chunks are recycled for reuse or returned to the OS. The Java Hotspot manages Metadata space as follows: firstly, the JVM requests an amount of space to the OS. Check the Heap dump of your application to find offending Classes.Learn how to monitor the MetaSpace in a running Java application.Understand how the JVM manages the MetaSpace data.In order to find the Root cause, we recommend that you follow these steps: ![]() On the other hand, if you see this error at runtime, we recommend to investigate on the Root cause of the problem before increasing blindly the MaxMetaspaceSize. For example, if you can see the error upon application start up. In conclusion, setting a high value for MaxMetaspaceSize, increase the chances of OutOfMemoryError: Metaspace What is the solution ?īy increasing the upper limit of the attribute MaxMetaspaceSize might solve the issue in some cases. ![]() The default value of MaxMetaspaceFreeRatio is 70. When the percentage of free space in the metaspace drops below this threshold, the JVM will attempt to free up space by unloading classes that are no longer in use. MaxMetaspaceFreeRatio is a JVM option that sets the percentage of free space that the JVM should attempt to maintain in the metaspace. Why ? Because there is a setting, MaxMetaspaceFreeRatio, which prevents the Metaspace from growing too much. committed) will be, generally, smaller than that. On the other hand, if you want to limit the amount of memory allocated for Java classes, you can set it as follows: java -XX:MaxMetaspaceSize=3200m In Java 8 and later, the maximum amount of memory allocated for Java classes ( MaxMetaspaceSize) is by default unlimited, so in most cases there is no need to change this setting. In general terms, the more classes you are loading into the JVM, the more memory will be consumed by the metaspace. Let’s how this issue can be solved in standalone applications and cloud applications. The : Metaspace indicates that the amount of native memory allocated for Java class metadata is exausted.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |