Skip to content

Commit 10a9b94

Browse files
committed
add available memory check
1 parent ba01bda commit 10a9b94

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

photon-core/src/main/java/org/photonvision/vision/pipeline/FrameRecorder.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.concurrent.atomic.AtomicBoolean;
2424
import org.opencv.core.Mat;
2525
import org.opencv.imgcodecs.Imgcodecs;
26+
import org.photonvision.common.hardware.HardwareManager;
2627
import org.photonvision.common.logging.LogGroup;
2728
import org.photonvision.common.logging.Logger;
2829
import org.photonvision.vision.opencv.CVMat;
@@ -67,6 +68,17 @@ static RecordFrame poison() {
6768
public FrameRecorder(Path outputPath, RecordingStrategy strat) {
6869
this.logger = new Logger(FrameRecorder.class, LogGroup.VisionModule);
6970

71+
double availableSpace = HardwareManager.getInstance().metricsManager.getDiskSpaceAvailable();
72+
73+
// Check if we're under 4 GB of available space, if so exit
74+
if (availableSpace < 4 * 1024 * 1024) {
75+
logger.error(
76+
"Low disk space available ("
77+
+ availableSpace / 1024
78+
+ " MB). FrameRecorder will not start.");
79+
throw new IllegalStateException("Insufficient disk space for FrameRecorder");
80+
}
81+
7082
logger.info("Initializing FrameRecorder with output path: " + outputPath.toString());
7183
this.outputPath = outputPath;
7284

0 commit comments

Comments
 (0)