Informix

 View Only
  • 1.  Informix JDBC driver cleanup bug - memory leak

    Posted 23 days ago

    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
    ------------------------------


  • 2.  RE: Informix JDBC driver cleanup bug - memory leak

    Posted 23 days ago

    What version of the JDBC driver?



    ------------------------------
    Øyvind Gjerstad
    Developer/Architect
    PostNord AS
    ------------------------------



  • 3.  RE: Informix JDBC driver cleanup bug - memory leak

    Posted 23 days ago

    The latest found on mvnrepository: 

    <dependency>
        <groupId>com.ibm.informix</groupId>
        <artifactId>jdbc</artifactId>
        <version>4.50.10.1</version>
    </dependency>



    ------------------------------
    Kristian Arlt
    ------------------------------



  • 4.  RE: Informix JDBC driver cleanup bug - memory leak

    Posted 22 days ago

    Ok, we are using 4.50.9. Not exactly same environment, though, we are using jboss, not tomcat. Haven't noticed this problem.



    ------------------------------
    Øyvind Gjerstad
    Developer/Architect
    PostNord AS
    ------------------------------



  • 5.  RE: Informix JDBC driver cleanup bug - memory leak
    Best Answer

    Posted 22 days ago

    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
    ------------------------------



  • 6.  RE: Informix JDBC driver cleanup bug - memory leak

    Posted 22 days ago

    From which version of the JDBC driver are these connection cleaner threads used?



    ------------------------------
    Øyvind Gjerstad
    Developer/Architect
    PostNord AS
    ------------------------------



  • 7.  RE: Informix JDBC driver cleanup bug - memory leak

    Posted 22 days ago

    I think the feature is available since JDBC 4.10.JC12. Maybe someone from IBM can correct me...

    Cheers,
    Markus



    ------------------------------
    Markus Holzbauer
    ------------------------------



  • 8.  RE: Informix JDBC driver cleanup bug - memory leak

    Posted 21 days ago

    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
    ------------------------------



  • 9.  RE: Informix JDBC driver cleanup bug - memory leak

    Posted 17 days ago

    Thank you @Markus Holzbauer for the quick reply, I added the IFMXCONNECTION_CLEANER_THREADS parameter to our connection string and the Warning is gone. After also analyzing the memory usage, Tomcat memory usage stays steady.



    ------------------------------
    Kristian Arlt
    ------------------------------