0

A Keycloak/JBoss server running using Java 8 was switched to G1GC and a -XX:MaxMetaspaceSize was set to 256MB. It soon stopped responding with logs filling up with OutOfMemory: Metaspace errors. GC logs were not enabled. Server was hooked with Dynatrace monitoring service which showed plenty of metapsace available.

191MB used out of 256MB allocated on one occasion. 165MB used out of 256MB allocated on a second occurrence.

I understand that to free metaspace, GC was invoked and being unable to free enough space it was running GC after GC so it makes sense why the process was stuck. However, what I am unable to understand is why process was running out of metaspace even when plenty was free. No other JVM parameter was provided (except XMS/XMX). All heap memory sections had plenty of free space. Was something trying to allocate 60MB+ space in metaspace? Is this the only possible reason?

  • Another reason could be that you are looking on average values and not maximum values. Add the meta space metric into a custom chart and ensure select "maximum" aggregation. Maybe then the values are closer to the max. – rmunge Oct 09 '20 at 13:13
  • Do you have `UseCompressedClassesPointers` enabled? If it so, then MaxMetaspaceSize = Committed size of (Metaspace+ Compressed class space). You might not set it explicitly but it is enabled by default if `UseCompressedOops` is turned on. So, kindly check your configuration. – suv3ndu Oct 16 '20 at 14:22
  • @rmunge This could be possible but used mataspace size shown in dynatrace is consistent which makes me think it is not growing or shrinking. – Haris Mushtaq Nov 03 '20 at 16:54
  • @suv3ndu That's interesting as UseCompressedOops was indeed included in JVM args. Is there any documentation/reference where this is explained? – Haris Mushtaq Nov 03 '20 at 18:39
  • @HarisMushtaq Please see [this](https://docs.oracle.com/javase/10/gctuning/other-considerations.htm#JSGCT-GUID-B29C9153-3530-4C15-9154-E74F44E3DAD9) for details. – suv3ndu Nov 04 '20 at 11:01

0 Answers0