Observing memory leak in CachingSessionFactory ( DefaultSftpSessionFactory)

294 views Asked by At

We have build spring microservice which uses spring integration framework with Rabbit mq as messaging system. Our application establish the sftp session with SFTP server and poll the files every 3 seconds. In a day we get around 5oo files and we are using CacheSessionFactory and DefaultSessionFactory with spring integration version 5.2.3. However, we observed three 3 different issues :

  1. Over the period of time , in production we observed that there is memory leak. There are lots of SftpSession objects are remining in memory.
  2. Intermittently we are getting error as "Failed to obtain Pooled item".
  3. One or 2 time, we observed the Poller thread is getting stuck and had to restart the system.

Number of SFTP session objects

Dominator Tree

CacheSessionFactory

We have this simple instantiation of DefaultSessionFactory and CacheSessionFactory.


DefaultSftpSessionFactory sessionFactory = new DefaultSftpSessionFactory();

    sessionFactory.setHost(sftpHost);
    sessionFactory.setPort(sftpPort);


    sessionFactory.setUser(sftpUser);
    sessionFactory.setPassword(sftpPassword);
    sessionFactory.setAllowUnknownKeys(true);
    return sessionFactory;

}


public CachingSessionFactory cachingSessionFactory(DefaultSftpSessionFactory defaultSftpSessionFactory) { CachingSessionFactory csf = new CachingSessionFactory(defaultSftpSessionFactory); return csf; }


0

There are 0 answers