Skip to content

Commit

Permalink
Fix massive memory leak in previews (#679) (#680)
Browse files Browse the repository at this point in the history
* Fix massve memory leak in lines previews

* Fix memory leak in blobs preview
  • Loading branch information
SamCarlberg authored and JLLeitschuh committed Oct 10, 2016
1 parent f84d379 commit 7f1498c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class BlobsSocketPreviewView extends SocketPreviewView<BlobsReport> {
private final ImageView imageView = new ImageView();
private final Label infoLabel = new Label();
private final Mat tmp = new Mat();
private final Point point = new Point();
private final GripPlatform platform;
@SuppressWarnings("PMD.ImmutableField")
@SuppressFBWarnings(value = "IS2_INCONSISTENT_SYNC",
Expand Down Expand Up @@ -91,7 +92,8 @@ private void convertImage() {
if (!blobsReport.getBlobs().isEmpty()) {
// For each line in the report, draw a line along with the starting and ending points
for (BlobsReport.Blob blob : blobsReport.getBlobs()) {
final Point point = new Point((int) blob.x, (int) blob.y);
point.x((int) blob.x);
point.y((int) blob.y);
circle(tmp, point, (int) (blob.size / 2), Scalar.WHITE, 2, LINE_8, 0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class LinesSocketPreviewView extends SocketPreviewView<LinesReport> {
private final ImageView imageView = new ImageView();
private final Label infoLabel = new Label();
private final Mat tmp = new Mat();
private final Point startPoint = new Point();
private final Point endPoint = new Point();
private final GripPlatform platform;
@SuppressWarnings("PMD.ImmutableField")
@SuppressFBWarnings(value = "IS2_INCONSISTENT_SYNC",
Expand Down Expand Up @@ -99,8 +101,10 @@ private void convertImage() {

// For each line in the report, draw a line along with the starting and ending points
for (LinesReport.Line line : lines) {
final Point startPoint = new Point((int) line.x1, (int) line.y1);
final Point endPoint = new Point((int) line.x2, (int) line.y2);
startPoint.x((int) line.x1);
startPoint.y((int) line.y1);
endPoint.x((int) line.x2);
endPoint.y((int) line.y2);
line(input, startPoint, endPoint, Scalar.WHITE, 2, LINE_8, 0);
circle(input, startPoint, 2, Scalar.WHITE, 2, LINE_8, 0);
circle(input, endPoint, 2, Scalar.WHITE, 2, LINE_8, 0);
Expand Down

0 comments on commit 7f1498c

Please sign in to comment.