vendredi 27 février 2015

Memory leak in Derby database while executing Timer task



I have strange situation. When executing this code, NetBeansIDE profiler shows memory leak (and after some time elapses, application quit because of insufficient memory):



public class SomeClass extends TimerTask {

private static final Timer timer = new Timer();

public SomeClass() {
//Delay 0, repeat every 20ms
timer.scheduleAtFixedRate(SomeClass.this, 0, 20);
}

@Override
public void run() {

try (Connection connDB =
DriverManager.getConnection(
"jdbc:derby:someDataBase;create=true");
Statement st = connDB.createStatement()) {
//Some code in normal situation. But the problem
//exists even without additional code..
} catch (SQLException ex) {
Logger.getLogger(SomeClass.class.getName()).log(
Level.SEVERE, null, ex);
}
}
}


Here are the snapshots:



enter image description here Memory (Heap)



enter image description here Memory (GC) - Surviving generations



Is this some Derby database bug?

Running on JDK8_u31, Derby version/package: db-derby-10.11.1.1-lib.


EDIT 1: When switched to HSQLDB database - no more memory leaks occurred while thousands of connections were opened and closed:



enter image description here Wow! :)



enter image description here




Aucun commentaire:

Enregistrer un commentaire