Skip to content

Commit 7f1498c

Browse files
SamCarlbergJLLeitschuh
authored andcommitted
Fix massive memory leak in previews (#679) (#680)
* Fix massve memory leak in lines previews * Fix memory leak in blobs preview
1 parent f84d379 commit 7f1498c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ui/src/main/java/edu/wpi/grip/ui/preview/BlobsSocketPreviewView.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class BlobsSocketPreviewView extends SocketPreviewView<BlobsReport> {
3838
private final ImageView imageView = new ImageView();
3939
private final Label infoLabel = new Label();
4040
private final Mat tmp = new Mat();
41+
private final Point point = new Point();
4142
private final GripPlatform platform;
4243
@SuppressWarnings("PMD.ImmutableField")
4344
@SuppressFBWarnings(value = "IS2_INCONSISTENT_SYNC",
@@ -91,7 +92,8 @@ private void convertImage() {
9192
if (!blobsReport.getBlobs().isEmpty()) {
9293
// For each line in the report, draw a line along with the starting and ending points
9394
for (BlobsReport.Blob blob : blobsReport.getBlobs()) {
94-
final Point point = new Point((int) blob.x, (int) blob.y);
95+
point.x((int) blob.x);
96+
point.y((int) blob.y);
9597
circle(tmp, point, (int) (blob.size / 2), Scalar.WHITE, 2, LINE_8, 0);
9698
}
9799
}

ui/src/main/java/edu/wpi/grip/ui/preview/LinesSocketPreviewView.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public class LinesSocketPreviewView extends SocketPreviewView<LinesReport> {
4040
private final ImageView imageView = new ImageView();
4141
private final Label infoLabel = new Label();
4242
private final Mat tmp = new Mat();
43+
private final Point startPoint = new Point();
44+
private final Point endPoint = new Point();
4345
private final GripPlatform platform;
4446
@SuppressWarnings("PMD.ImmutableField")
4547
@SuppressFBWarnings(value = "IS2_INCONSISTENT_SYNC",
@@ -99,8 +101,10 @@ private void convertImage() {
99101

100102
// For each line in the report, draw a line along with the starting and ending points
101103
for (LinesReport.Line line : lines) {
102-
final Point startPoint = new Point((int) line.x1, (int) line.y1);
103-
final Point endPoint = new Point((int) line.x2, (int) line.y2);
104+
startPoint.x((int) line.x1);
105+
startPoint.y((int) line.y1);
106+
endPoint.x((int) line.x2);
107+
endPoint.y((int) line.y2);
104108
line(input, startPoint, endPoint, Scalar.WHITE, 2, LINE_8, 0);
105109
circle(input, startPoint, 2, Scalar.WHITE, 2, LINE_8, 0);
106110
circle(input, endPoint, 2, Scalar.WHITE, 2, LINE_8, 0);

0 commit comments

Comments
 (0)