Memory Leak Warning in the Logs

I’ve been running into an issue with almost daily lucee restarts. This particular server stack:

OS: Windows Server 2019 Standard
Java Version: 21.0.6 (Eclipse Adoptium) 64bit
Tomcat Version: Apache Tomcat/9.0.62
Lucee Version: 6.2.1.122

The logs are stating a possible memory leak - 13-Jun-2025 05:56:24.031 WARNING [Thread-521962] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [Thread-127] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base/java.lang.Object.wait0(Native Method)
java.base/java.lang.Object.wait(Unknown Source)
lucee.runtime.spooler.SpoolerEngineImpl$SpoolerThread.doWait(SpoolerEngineImpl.java:515)
lucee.runtime.spooler.SpoolerEngineImpl$SpoolerThread.run(SpoolerEngineImpl.java:485)
13-Jun-2025 05:56:24.031 WARNING [Thread-521962] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesObjectStreamClassCaches Failed to clear soft references from ObjectStreamClass$Caches for web application [ROOT]
java.lang.ClassCastException: class java.io.ObjectStreamClass$Caches$1 cannot be cast to class java.util.Map (java.io.ObjectStreamClass$Caches$1 and java.util.Map are in module java.base of loader ‘bootstrap’)
at org.apache.catalina.loader.WebappClassLoaderBase.clearCache(WebappClassLoaderBase.java:2336)
at org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesObjectStreamClassCaches(WebappClassLoaderBase.java:2311)
at org.apache.catalina.loader.WebappClassLoaderBase.clearReferences(WebappClassLoaderBase.java:1674)
at org.apache.catalina.loader.WebappClassLoaderBase.stop(WebappClassLoaderBase.java:1602)
at org.apache.catalina.loader.WebappLoader.stopInternal(WebappLoader.java:463)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5515)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1412)
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1401)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:986)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1412)
at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1401)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:986)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
at org.apache.catalina.core.StandardService.stopInternal(StandardService.java:497)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:979)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:656)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:391)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:481)

Is this caused by the scheduled task spooler? If so should I move the scheduled tasks to the OS level? There are quite a few as this server is mainly for running imports, exports and automated routines.

Java startup options:
-Dcatalina.home=C:\lucee\tomcat
-Dcatalina.base=C:\lucee\tomcat
-Dignore.endorsed.dirs=C:\lucee\tomcat\endorsed
-Djava.io.tmpdir=C:\lucee\tomcat\temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=C:\lucee\tomcat\conf\logging.properties
-Dorg.apache.tomcat.websocket.DISABLE_BUILTIN_EXTENSIONS=true
-XX:+UseZGC
-XX:MetaspaceSize=128m
-XX:MaxMetaspaceSize=768m
-XX:ParallelGCThreads=2
-XX:+DisableExplicitGC

Initial memory pool: 5000
Max memory pool: 8000

What else should I look for? I have another server, Windows 2012 running lucee 6.1.1.118 on Java 11.0.24 (Eclipse Adoptium) 64bit that never seems to have this issue. It also has no scheduled tasks…

Are you only restarting daily because you see this warning?

I’d suggest first upgrading your Tomcat to version 11

9.0.62 is really, really old and you are missing out on all the java 21 virtual thread goodness performance wise

No, the restarts have been due to Lucee being non responsive. I’ve been putting off that upgrade. I cannot find a reliable source of information for an inline upgrade for Tomcat on Windows as what I’ve tried in the past broke the install. Do you have a suggestion for and inline upgrade or do a fresh install of Lucee?

I highly recommend just doing a fresh install

That was the fix, I don’t see any errors in the logs and I’ve not had to restart lucee. Thank you very much!

2 Likes

excellent, thanks for letting me know it worked!

1 Like

well… spoke too soon. Now I’m getting this error: No connection could be made because the target machine actively refused it [::1]:8009 after running for several hours. Is Tomcat binding to ipv6 and if so can I turn that off to only bind to ipv4? Or is this a setting that need adjusted in Boncode? I’m using boncode 1.0.44

I haven’t used boncode much myself to be honest!

the default is just localhost

Was lucee still responding on 8888 ? anything else in the logs, odd that it just stopped working after a while

background on this Remove address from ajp connector config · Issue #102 · viviotech/lucee-installer · GitHub

I did not check if lucee was responding on port 8888 but I will in the future. However I do see that the hosts file in Windows has the ::1 localhost line commented out. Should that line be uncommented?

dunno! probably best to change the local host in that ini file to 127.0.0.1?

re the ajp errors, can you check the tomcat/logs to see if there are any errors?