Lucee Error (java.lang.OutOfMemoryError)

We suddenly started getting this error on one file, on one application on our server and all the following server.cfm and web.cfm

Lucee Error (java.lang.OutOfMemoryError)
Message Metaspace
Java Stacktrace lucee.runtime.exp.NativeException: Metaspace
Caused by: java.lang.OutOfMemoryError: Metaspace

Errors on the following

But does not error on

Any ideas, we have tried rolling back code and have similar code on another app that works.

It was MetaSpace. Viviotech doubled it from 1GB to 2GB for us. Its works fine now.

Occasionally i get the same error. afterwards the service has to be restarted.

"ERROR","http-nio-8888-exec-42","12/02/2019","18:55:59","",";Metaspace;lucee.runtime.exp.NativeException: Metaspace
Caused by: java.lang.OutOfMemoryError: Metaspace

We use the following configuration

CATALINA_OPTS="-Xms6144m -Xmx6144m -XX:+UseG1GC -XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=512m -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:InitiatingHeapOccupancyPercent=70 -XX:G1ReservePercent=15 -XX:ParallelGCThreads=20 -XX:ConcGCThreads=5 -XX:+AggressiveOpts";

Would you advise us to increase the value here?
-XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=512m

How big should XX:MetaspaceSize be in relation to Xms/Xmx?

Best regards

@dbleisch There is no direct correlation to heap size and Metaspace size.

The metaspace is used by the JVM to store java class metadata (your CFML gets compiled into a java class), so essentially it depends on how much code you have. You can have a 1 cfm application that uses a ton of heap, but will utilize very little metaspace, and you can have a huge application that has many cfm/cfc, but uses very little heap.

It is worth noting that the default MaxMetaspaceSize is unbounded, so if you don’t specify it the JVM will let it grow as needed. It should work fine unbounded unless you have a case where you are dynamically compiling cfml templates.

Pete Freitag

1 Like

Great, thanks for the hint regarding unbound MaxMetaspaceSize.