diff --git a/src/PamguardMVC/PamObservable.java b/src/PamguardMVC/PamObservable.java index 73897998..da6a540b 100644 --- a/src/PamguardMVC/PamObservable.java +++ b/src/PamguardMVC/PamObservable.java @@ -400,7 +400,7 @@ public class PamObservable {//extends PanelOverlayDraw { } } - private Timer t = new Timer(1000, new ActionListener() { + private Timer t = new Timer(4321, new ActionListener() { public void actionPerformed(ActionEvent evt) { long now = System.currentTimeMillis(); if (cpuUsage == null) return; @@ -412,6 +412,16 @@ public class PamObservable {//extends PanelOverlayDraw { lastCPUCheckTime = now; } }); + + + /** + * Had some issues with the Timer holding a reference to the underlying PamDataBlock + * (RoccaContourDataBlock, in this case) and not releasing it for garbage collection. + * Added in this method to force the timer to stop and release it's hold. + */ + public void stopTimer() { + t.stop(); + } public double getCPUPercent(int objectIndex) { if (objectIndex < 0 || objectIndex >= cpuPercent.length) return -1; diff --git a/src/rocca/RoccaProcess.java b/src/rocca/RoccaProcess.java index b21709df..71847953 100644 --- a/src/rocca/RoccaProcess.java +++ b/src/rocca/RoccaProcess.java @@ -388,7 +388,9 @@ public class RoccaProcess extends PamProcess { rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) > 1.5 || rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQABSSLOPEMEAN) < 2000. || rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQABSSLOPEMEAN) > 28000. )) { - rcdb.setNaturalLifetimeMillis(0); +// rcdb.setNaturalLifetimeMillis(0); + rcdb.stopTimer(); + rcdb = null; return; } if (roccaControl.roccaParameters.roccaClassifierModelFilename.getName().equals("HIWhist.model") && @@ -402,7 +404,9 @@ public class RoccaProcess extends PamProcess { rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQABSSLOPEMEAN) > 60000. || rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQRANGE) < 800. || rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQRANGE) > 14000. )) { - rcdb.setNaturalLifetimeMillis(0); +// rcdb.setNaturalLifetimeMillis(0); + rcdb.stopTimer(); + rcdb = null; return; } if (roccaControl.roccaParameters.roccaClassifierModelFilename.getName().equals("NWAtlWhist.model") && @@ -412,7 +416,9 @@ public class RoccaProcess extends PamProcess { rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) > 2.5 || rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQABSSLOPEMEAN) < 9100. || rcdb.getContour().get(RoccaContourStats.ParamIndx.FREQABSSLOPEMEAN) > 82000. )) { - rcdb.setNaturalLifetimeMillis(0); +// rcdb.setNaturalLifetimeMillis(0); + rcdb.stopTimer(); + rcdb = null; return; } } @@ -431,7 +437,9 @@ public class RoccaProcess extends PamProcess { saveContourPoints(rcdb, rcdb.getChannelMap(), ++numDetections, sNum); saveContourStats(rcdb, rcdb.getChannelMap(), numDetections, sNum); saveContour(rcdb, rcdb.getChannelMap(), numDetections, sNum); - rcdb.setNaturalLifetimeMillis(0); +// rcdb.setNaturalLifetimeMillis(0); + rcdb.stopTimer(); + rcdb = null; /* if this is a click detection (signal, not noise) */ } else if (o==manClickSourceData || o==autoClickSourceData) { @@ -499,18 +507,24 @@ public class RoccaProcess extends PamProcess { (rcdb.getContour().get(RoccaContourStats.ParamIndx.SNR) > 35. || rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) < 0.005 || rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) > 0.6 )) { + rcdb.stopTimer(); + rcdb = null; return; } if (roccaControl.roccaParameters.roccaClassifierModelFilename.getName().equals("HIClick.model") && (rcdb.getContour().get(RoccaContourStats.ParamIndx.SNR) > 40. || rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) < 0.01 || rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) > 0.6 )) { + rcdb.stopTimer(); + rcdb = null; return; } if (roccaControl.roccaParameters.roccaClassifierModelFilename.getName().equals("NWAtlClick.model") && (rcdb.getContour().get(RoccaContourStats.ParamIndx.SNR) > 35. || rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) < 0.005 || rcdb.getContour().get(RoccaContourStats.ParamIndx.DURATION) > 0.6 )) { + rcdb.stopTimer(); + rcdb = null; return; } } @@ -529,7 +543,9 @@ public class RoccaProcess extends PamProcess { // add call to update side panel. Set the isClick flag to True updateSidePanel(rcdb, true); saveContourStats(rcdb, rcdb.getChannelMap(), numDetections, sNum); - rcdb.setNaturalLifetimeMillis(0); +// rcdb.setNaturalLifetimeMillis(0); + rcdb.stopTimer(); + rcdb = null; }