updates to Rocca module (#85)

* allow Rocca to run without classifiers

Fixed bug that threw an error if no classifier files were specified in Rocca Params dialog

* add rocca switch to enable dev mode

currently only shows/hides extra buttons in the Params dialog, but will
extend to more options in the future

* Fix memory issue with RoccaContourDataBlocks not being released for
garbage collection

Set RoccaContourDataBlock objects to null and stop PamObserver Timer to
force release
This commit is contained in:
m2oswald 2022-11-15 15:41:43 +00:00 committed by GitHub
parent 655a546764
commit ac280e1b6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 6 deletions

View File

@ -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;
@ -413,6 +413,16 @@ public class PamObservable {//extends PanelOverlayDraw {
}
});
/**
* 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;
return cpuPercent[objectIndex];

View File

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