ROCCA Fix (#90)

* Version 2.02.06

(hopefully)

* ROCCA Memory leak

Another attempt at healing ROCCA memory leak
This commit is contained in:
Douglas Gillespie 2022-11-21 09:13:59 +00:00 committed by GitHub
parent 3203a0a50f
commit c32d172000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 7 deletions

View File

@ -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" );

View File

@ -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) {

View File

@ -1574,6 +1574,28 @@ public class RoccaContourDataBlock extends PamDataBlock<RoccaContourDataUnit> {
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;
// }
//
}

View File

@ -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;
}