观察CachingsessionFactory中的内存泄漏(默认sftpSessionFactory)

发布于 2025-01-21 14:59:56 字数 1270 浏览 3 评论 0原文

我们已经建立了Spring Microservice,该微服务将春季集成框架与兔子MQ用作消息系统。我们的应用程序与SFTP服务器建立了SFTP会话,并每3秒钟对文件进行轮询。一天中,我们将获得5oo文件,我们使用CachesessionFactorydefaultSessionFactory,带有Spring Integration版本5.2.3。但是,我们观察到三个三个不同的问题:

  1. 在整个时间内,在生产中,我们观察到内存泄漏。有很多sftpsession对象在存储器中浮出水面。
  2. 间歇性地,我们正在遇到错误,因为“无法获得汇总项目”。
  3. 一到两次,我们观察到投票程序的线程被卡住了,必须重新启动系统。

sftp sessignobsocts

dominator树

=“ nofollow noreferrer ”这种简单的默认空间和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(默认sftpsessionFactory defaultsftpsessionFactory){ CachingsessionFactory CSF =新的CachingsessionFactory(DefaultSftPsessionFactory); 返回CSF; }


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


如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文