mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
ROCCA Fix (#90)
* Version 2.02.06 (hopefully) * ROCCA Memory leak Another attempt at healing ROCCA memory leak
This commit is contained in:
parent
3203a0a50f
commit
c32d172000
@ -391,7 +391,7 @@ public class PamDataBlock<Tunit extends PamDataUnit> extends PamObservable {
|
||||
isNetworkReceive = PamController.getInstance().getRunMode() == PamController.RUN_NETWORKRECEIVER;
|
||||
|
||||
if (!isOffline) {
|
||||
t.start();
|
||||
removeTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
@ -469,7 +469,7 @@ public class PamDataBlock<Tunit extends PamDataUnit> 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<Tunit extends PamDataUnit> 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" );
|
||||
|
@ -93,7 +93,7 @@ public class PamObservable {//extends PanelOverlayDraw {
|
||||
pamObservers = new ArrayList<PamObserver>();
|
||||
instantObservers = new ArrayList<PamObserver>();
|
||||
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) {
|
||||
|
@ -1576,4 +1576,26 @@ public class RoccaContourDataBlock extends PamDataBlock<RoccaContourDataUnit> {
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
// }
|
||||
//
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user