The cleaner thread was introduced way back, before 4.10.JC6 even if I recall. But the ability to turn it off was introduced much later. Currently the default value is 1 thread. The point of this thread was to help with developers who didn't understand they needed to close connections after they used them (think back before try-with-resources feature or web frameworks like Spring were built in java).
My opinion the feature should not ever be enabled if you are using a framework and web servers like Tomcat or Spring to manage connections for you. I would just shut it off since those frameworks ensure connections are correctly closed when needed and pooled when wanted.
The lingering thread is a defect/bug but most of the time you don't even want it running in the first place so that's the easier solution for you I think. Should the default be 0? Probably yes, but unsure if someone will change it. Changing default behavior is always a tricky subject.
Hope this helps!
------------------------------
Brian Hughes
------------------------------
Original Message:
Sent: Thu June 13, 2024 03:45 AM
From: Markus Holzbauer
Subject: Informix JDBC driver cleanup bug - memory leak
I think the feature is available since JDBC 4.10.JC12. Maybe someone from IBM can correct me...
Cheers,
Markus
------------------------------
Markus Holzbauer
Original Message:
Sent: Thu June 13, 2024 03:40 AM
From: Øyvind Gjerstad
Subject: Informix JDBC driver cleanup bug - memory leak
From which version of the JDBC driver are these connection cleaner threads used?
------------------------------
Øyvind Gjerstad
Developer/Architect
PostNord AS
Original Message:
Sent: Thu June 13, 2024 03:27 AM
From: Markus Holzbauer
Subject: Informix JDBC driver cleanup bug - memory leak
Hello Kristian,
The connection cleaner thread has following properties:
IFMXCONNECTION_CLEANER_THREADS (defaults to 0)
IFMXCONNECTION_CLEANER_DELAY_MAXIMUM (defaults to 15000 msec/15 sec)
You can try to disalbe the connection cleaner thread with following Parameter in the connection string/URL:
;IFMXCONNECTION_CLEANER_THREADS=0
HTH,
Cheers,
Markus
------------------------------
Markus Holzbauer
Original Message:
Sent: Tue June 11, 2024 05:25 AM
From: Kristian Arlt
Subject: Informix JDBC driver cleanup bug - memory leak
I have a problem when hot deploying our Java service to Tomcat, when the app is restarted getting the following WARNING:
07-Jun-2024 14:18:12.815 WARNING [Catalina-utility-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [dashboard] appears to have started a thread named [IfxSqliConnectCleaner-Thread-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base/jdk.internal.misc.Unsafe.park(Native Method)
java.base/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:269)
java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1758)
java.base/java.util.concurrent.DelayQueue.poll(DelayQueue.java:305)
java.base/java.util.concurrent.DelayQueue.poll(DelayQueue.java:100)
com.informix.jdbc.IfxSqliConnect$IfxSqliConnectCleaner.run(IfxSqliConnect.java:645)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
java.base/java.lang.Thread.run(Thread.java:1583)
This can be reproduced by consecutive WAR deployments, so that the memory usage increases after each time the service is restarted.
I was wondering if the JDBC driver could be enhanced to help close all resources.
------------------------------
Kristian Arlt
------------------------------