java memory virtual machine System Administrator Jahia 8 Jahia 7.3

How to fix error java.lang.OutOfMemoryError: Metaspace

Question

My application is throwing the following error:

ERROR [INT-2,shared=tcp-jahia-shared] org.jgroups.protocols.TCP: JGRP000030: null: failed handling incoming message: java.lang.OutOfMemoryError: Metaspace

But the heap memory allocation of my application is fine and not fully used.

How can I fix this error?

Answer

Such errors might happen if you set the flag 

-XX:MaxMetaspaceSize=<value>

In the CATALINA_OPS variable to initialize your java virtual machine.

You can verify the presence of this flag in CATALINA_OPS variable using the Export Support Information tool under <JAHIA_SERVER>/modules/tools/support.jsp selecting the option Properties -> Environment Variables

If this flag is present, you can increase its value to fix the OutOfMemory issues.

Jahia does not add this flag by default so please make sure you review Oracle documentation about memory assignment flags for Java Virtual Machines