gpt4 book ai didi

java - 调用存储过程时内存泄漏

转载 作者:行者123 更新时间:2023-11-30 06:36:02 25 4
gpt4 key购买 nike

我的程序某处发生内存泄漏,使用一些工具我认为这是我代码中的位置。那么,这个函数是不是有问题,存储过程是怎么调用的呢?

CustomSQLConn 是在类创建的时候给的。

private void flagDeleted(ABCDocument mydoc){
try {

ResultSet rs1 = null;
try{
CallableStatement cs1;
cs1 = CustomSQLConn.prepareCall("{ call flagFolderDeleted(?) }");
cs1.setInt(1, mydoc.getId());
cs1.execute();
}catch (Exception e){
System.out.println("Got an exception: " + e.getMessage());
e.printStackTrace();
}finally{
if(rs1 != null) rs1.close();
rs1 = null;
}
}catch (Exception e) {
System.out.println("Got an exception: " + e.getMessage());
e.printStackTrace();
}
} // END flagDeleted

这里也没有关闭连接,因为该类将它用于其他进程。

最佳答案

您正在关闭 ResultSet 但没有关闭 CallableStatement

关于java - 调用存储过程时内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5245985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com