mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-22 07:02:29 +00:00
ROCCA Memory leak
Another attempt at healing ROCCA memory leak
This commit is contained in:
parent
6f3992dc2d
commit
75b05a25e6
@ -391,7 +391,7 @@ public class PamDataBlock<Tunit extends PamDataUnit> extends PamObservable {
|
|||||||
isNetworkReceive = PamController.getInstance().getRunMode() == PamController.RUN_NETWORKRECEIVER;
|
isNetworkReceive = PamController.getInstance().getRunMode() == PamController.RUN_NETWORKRECEIVER;
|
||||||
|
|
||||||
if (!isOffline) {
|
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) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
int n;
|
int n;
|
||||||
if (shouldDelete()) {
|
if (shouldDelete()) {
|
||||||
@ -2413,6 +2413,25 @@ public class PamDataBlock<Tunit extends PamDataUnit> extends PamObservable {
|
|||||||
return unitClass;
|
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() {
|
public void autoSetDataBlockMixMode() {
|
||||||
if (AcousticDataUnit.class.isAssignableFrom(unitClass)) {
|
if (AcousticDataUnit.class.isAssignableFrom(unitClass)) {
|
||||||
// System.out.println(unitClass + " is acoustic data" );
|
// System.out.println(unitClass + " is acoustic data" );
|
||||||
|
@ -93,7 +93,7 @@ public class PamObservable {//extends PanelOverlayDraw {
|
|||||||
pamObservers = new ArrayList<PamObserver>();
|
pamObservers = new ArrayList<PamObserver>();
|
||||||
instantObservers = new ArrayList<PamObserver>();
|
instantObservers = new ArrayList<PamObserver>();
|
||||||
pamProfiler = PamProfiler.getInstance();
|
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) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (cpuUsage == null) return;
|
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.
|
* Added in this method to force the timer to stop and release it's hold.
|
||||||
*/
|
*/
|
||||||
public void stopTimer() {
|
public void stopTimer() {
|
||||||
t.stop();
|
cpuTimer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getCPUPercent(int objectIndex) {
|
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);
|
updateSidePanel(rcdb, true);
|
||||||
saveContourStats(rcdb, rcdb.getChannelMap(), numDetections, sNum);
|
saveContourStats(rcdb, rcdb.getChannelMap(), numDetections, sNum);
|
||||||
// rcdb.setNaturalLifetimeMillis(0);
|
// rcdb.setNaturalLifetimeMillis(0);
|
||||||
rcdb.stopTimer();
|
rcdb.dispose();
|
||||||
rcdb = null;
|
rcdb = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user