One of the following pieces of code generates a memory leak, any idea which part?
1)
private Deque<Snapshot> snapshots = new LinkedList<Snapshot>();
Iterator<Snapshot> i = world.getSnapshots().descendingIterator();
while (i.hasNext()) {
Snapshot s = i.next();
if (curTime - s.getTimestamp() > 60000) {
i.remove();
} else {
break;
}
}
2)
public static void initilizePreparedStatements() {
try {
insertNewReportRow = Instance.getWorld().getDB().getConnection().prepareStatement("INSERT INTO `rsca2_reports` (`from`, `about`, `time`, `reason`, `snapshot_from`,`snapshot_about`,`chatlogs`, `from_x`, `from_y`, `about_x`, `about_y`) VALUES(?,?,?,?,?,?,?,?,?,?,?)");
} catch (SQLException e) {
e.printStackTrace();
Logger.error(e);
}
}
public synchronized static void submitReport() {
/*removed*/
try {
insertNewReportRow.setLong(1, from);
insertNewReportRow.setLong(2, about);
insertNewReportRow.setLong(3, time);
insertNewReportRow.setInt(4, reason);
insertNewReportRow.setString(5, snapshot_from);
insertNewReportRow.setString(6, snapshot_about);
insertNewReportRow.setString(7, chatlog);
insertNewReportRow.setInt(8, f.getX());
insertNewReportRow.setInt(9, f.getY());
insertNewReportRow.setInt(10, a.getX());
insertNewReportRow.setInt(11, a.getY());
insertNewReportRow.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
Logger.error(e);
}
}