I just moved from grails 2.4.3 to grails 2.5.6 and from Java 7 to Java 8. I'm trying to set optimal metaspace size in my app.
Actual metaspace size has big impact on application performance:
Used metaspace and response avg time:
Metaspace is growing from application start to 620MB in 90 minutes.
This is my actual gc settings:
-Xms14G -Xmx14G\
-XX:+UseG1GC\
-XX:ParallelGCThreads=8\
-XX:ConcGCThreads=4\
-XX:MaxGCPauseMillis=200\
-XX:+UseLargePages\
-XX:+UseLargePagesInMetaspace\
-XX:+AlwaysPreTouch\
-XX:InitialBootClassLoaderMetaspaceSize=512M\
-XX:MetaspaceSize=512M\
-XX:MinMetaspaceExpansion=8M\
-XX:MaxMetaspaceExpansion=32M\
-XX:+UseStringDeduplication\
-XX:+ParallelRefProcEnabled\
-XX:-TieredCompilation\
When MaxMetaspaceSize was set to 512M then after few hours of running my app is slowing down 1 or 2 times for hour. Respons time is around 10 seconds then.
Anyone had such problem? In yours applications metaspace has such impact on performance?
OutOfMemoryError: Metaspace error is thrown. To mitigate the issue, you can increase the size of the Metaspace by adding the -XX:MaxMetaspaceSize flag to startup parameters of your Java application. For example, to set the Metaspace region size to 128M, you would add the following parameter: -XX:MaxMetaspaceSize=128m .
Metaspace by default auto increases its size depending on the underlying OS. Contiguous Java Heap Memory. Native Memory(provided by underlying OS). Inefficient garbage collection.
Metaspace is a native memory region that stores metadata for classes. As a class is loaded by the JVM, its metadata (i.e. its runtime representation in the JVM) is allocated into the Metaspace. The Metaspace occupancy grows as more and more classes are loaded.
Have you profiled your app?
I'd say that Metaspace garbage collection was involved here. It collects dead classes and classloaders and it's triggered once the class metadata usage reaches the MaxMetaspaceSize (which was narrowed by -XX:MaxMetaspaceSize
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With