使用 J2ssh jar 出现内存不足异常
我们在 web 应用程序中使用 j2ssh jar(j2ssh 是用于连接 Secured Shell 的外部 jar)。web 应用程序在 weblogic 服务器中运行。
我在finally块中打开像这样的连接
SshClient ssh = new SshClient();
SessionChannelClient session=null;
session = ssh.openSessionChannel();
,像这样关闭会话。
finally
{
System.out.println("disconnecting from ssh");
try
{
session.close();
}
catch(IOException ioe)
{
theOutput = ioe.getMessage();
System.out.println("IOException="+ioe);
}
}
我的疑问是我是否正确关闭了连接?它会清除Weblogic堆栈吗?因为我们经常收到用户因内存溢出而出现异常的抱怨,这基本上意味着垃圾收集没有正确发生。一旦我们重新启动服务器,它就会自动解决。有没有一种方法可以定期清除weblogic那么如何避免内存溢出异常呢?
We are using j2ssh jar(j2ssh is an external jar used to connect Secured Shell)in our webapp.The webapp is running in weblogic server.
I open the connection like this
SshClient ssh = new SshClient();
SessionChannelClient session=null;
session = ssh.openSessionChannel();
inside the finally block I close the session like this.
finally
{
System.out.println("disconnecting from ssh");
try
{
session.close();
}
catch(IOException ioe)
{
theOutput = ioe.getMessage();
System.out.println("IOException="+ioe);
}
}
My doubt is am I closing the connection properly? Will it clear the Weblogic stack because we are getting frequent complaints that users are getting exceptions due to memory overflow which basically means garbage collection is not happening properly.Once we restart the server it is automatically solved.Is there a way to periodically clear the weblogic memory so to avoid memory overflow exception?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该尝试在关闭会话后释放 session 和 ssh 对象,
就像在 catch 块之后一样,
You should try releasing the session and ssh object after closing session,
something like this after catch block,