I have a lucee (ColdFusion) server in production.
At first, we encountered OS memory exhaustion. We reduced the -Xmx2048m
to half available memory and set -XX:MaxMetaspaceSize=1000m
.
After a while though, the tomcat of lucee reported OutOfMemory errors and required a restart.
Since the metaspace is in addition to the heap and by default is not limited, this indicates that the metaspace is filling up.
I have then added a regular jcmd <pid> VM.metaspace
to verify this assumption.
In the morning, I have:
garbage-first heap total 1572864K, used 959885K [0x0000000080000000, 0x0000000100000000)
region size 1024K, 249 young (254976K), 18 survivors (18432K)
Metaspace used 99985K, capacity 102839K, committed 104996K, reserved 1114112K
class space used 7301K, capacity 8154K, committed 8320K, reserved 1015808K
and in the evening:
garbage-first heap total 1616896K, used 556546K [0x0000000080000000, 0x0000000100000000)
region size 1024K, 25 young (25600K), 5 survivors (5120K)
Metaspace used 108125K, capacity 111035K, committed 113828K, reserved 1122304K
class space used 7509K, capacity 8463K, committed 8704K, reserved 1015808K
So metaspace is growing by about 8Mb per day !
I had found that JAXB had an issue that cause this behavior, so I tried that walkaround by adding -Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true
but it didn't help or maybe made it worse.
How can I find out what the heck is filling up my metaspace ?