diff --git a/src/PamguardMVC/PamDataBlock.java b/src/PamguardMVC/PamDataBlock.java index e0c3b9f7..68a4ab25 100644 --- a/src/PamguardMVC/PamDataBlock.java +++ b/src/PamguardMVC/PamDataBlock.java @@ -391,7 +391,7 @@ public class PamDataBlock extends PamObservable { isNetworkReceive = PamController.getInstance().getRunMode() == PamController.RUN_NETWORKRECEIVER; if (!isOffline) { - t.start(); + removeTimer.start(); } } @@ -469,7 +469,7 @@ public class PamDataBlock extends PamObservable { // } } - Timer t = new Timer(500, new ActionListener() { + Timer removeTimer = new Timer(500, new ActionListener() { public void actionPerformed(ActionEvent evt) { int n; if (shouldDelete()) { @@ -2413,6 +2413,25 @@ public class PamDataBlock extends PamObservable { return unitClass; } + /** + * clean up datablock when it's no longer needed + */ + public void dispose() { + stopTimer(); + clearAll(); + } + + /** + * 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. + */ + @Override + public void stopTimer() { + super.stopTimer(); + removeTimer.stop(); + } + public void autoSetDataBlockMixMode() { if (AcousticDataUnit.class.isAssignableFrom(unitClass)) { // System.out.println(unitClass + " is acoustic data" ); diff --git a/src/PamguardMVC/PamObservable.java b/src/PamguardMVC/PamObservable.java index da6a540b..0d693c99 100644 --- a/src/PamguardMVC/PamObservable.java +++ b/src/PamguardMVC/PamObservable.java @@ -93,7 +93,7 @@ public class PamObservable {//extends PanelOverlayDraw { pamObservers = new ArrayList(); instantObservers = new ArrayList(); pamProfiler = PamProfiler.getInstance(); - t.start(); + cpuTimer.start(); } /** @@ -400,7 +400,7 @@ public class PamObservable {//extends PanelOverlayDraw { } } - private Timer t = new Timer(4321, new ActionListener() { + private Timer cpuTimer = new Timer(4321, new ActionListener() { public void actionPerformed(ActionEvent evt) { long now = System.currentTimeMillis(); if (cpuUsage == null) return; @@ -420,7 +420,7 @@ public class PamObservable {//extends PanelOverlayDraw { * Added in this method to force the timer to stop and release it's hold. */ public void stopTimer() { - t.stop(); + cpuTimer.stop(); } public double getCPUPercent(int objectIndex) { diff --git a/src/rocca/RoccaContourDataBlock.java b/src/rocca/RoccaContourDataBlock.java index b295088d..1672c93d 100644 --- a/src/rocca/RoccaContourDataBlock.java +++ b/src/rocca/RoccaContourDataBlock.java @@ -1574,6 +1574,28 @@ public class RoccaContourDataBlock extends PamDataBlock { public double[][] getWavInfo() { return wavInfo; } - + + +// int nS, nT; +// @Override +// protected int removeOldUnitsT(long currentTimeMS) { +// // TODO Auto-generated method stub +// nT++; +// System.out.printf("Enter removeoldUnitsT, entry count %d\n", nT); +// int n = super.removeOldUnitsT(currentTimeMS); +// nT--; +// return n; +// } +// +// @Override +// protected int removeOldUnitsS(long mastrClockSample) { +// // TODO Auto-generated method stub +// nS++; +// System.out.printf("Enter removeoldUnitsS, entry count %d\n", nS); +// int n = super.removeOldUnitsS(mastrClockSample); +// nS--; +// return n; +// } +// } diff --git a/src/rocca/RoccaProcess.java b/src/rocca/RoccaProcess.java index 71847953..7abe2577 100644 --- a/src/rocca/RoccaProcess.java +++ b/src/rocca/RoccaProcess.java @@ -544,7 +544,7 @@ public class RoccaProcess extends PamProcess { updateSidePanel(rcdb, true); saveContourStats(rcdb, rcdb.getChannelMap(), numDetections, sNum); // rcdb.setNaturalLifetimeMillis(0); - rcdb.stopTimer(); + rcdb.dispose(); rcdb = null; }