此代码中的内存泄漏在哪里?此函数执行数百万次,内存使用量很大,执行 240 万次后导致内存不足异常。
public static void saveCall(Call call) {
conn = getInstance();
if (conn != null) {
try {
calendar.setTime(call.getDate());
String sql = "INSERT INTO Calls(id, datetime, duration, customer_phone_id, partner_phone_id) "
+ "VALUES(null, ?, ?, ?, ?)";
PreparedStatement preparedStatement = conn
.prepareStatement(sql);
preparedStatement.setString(1, dateFormat.format(calendar.getTime()));
preparedStatement.setLong(2, call.getDuration());
preparedStatement.setLong(3, call.getPhone().getPhoneNumber());
preparedStatement.setLong(4, call.getPhonePartner()
.getPhoneNumber());
preparedStatement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
}