How can I avoid the "java.lang.OutOfMemoryError: Metaspace" error?
Estimated Reading Time: < 1 Minute
This error means that the Metaspace memory limit of the JVM has been reached.
This non-heap memory is used to store class descriptions, so this error may appear when running huge applications.
You can increase the Metaspace memory by adding two options to your command line, MaxMetaspaceSize and CompressedClassSpaceSize.
iscrun -J-XX:MaxMetaspaceSize=1g -J-XX:CompressedClassSpaceSize=1g PROGNAME
Or
java -XX:MaxMetaspaceSize=256m -XX:CompressedClassSpaceSize=256m PROGNAME1g means 1 GB and it specifies the maximum amount of non-heap memory that the JVM can allocate.
If it's not enough, try with higher values.
You can also get information about the Metaspace used and reserved from a heap dump, for instance:
Metaspace used 2425K, capacity 4498K, committed 4864K, reserved 1056768K class space used 262K, capacity 386K, committed 512K, reserved 1048576Kor with the JvisualVM or VisualVM tool: You can read more about these settings in our documentation's Appendices in the Runtime Errors section.