From ff8cd7b142ffa1a4e633697da3212e06507b7074 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Sat, 28 Jul 2018 18:55:03 +0800 Subject: [PATCH] fixed findBitmap and findPic memory leak --- robotgo.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/robotgo.go b/robotgo.go index 6d80aba..6323576 100644 --- a/robotgo.go +++ b/robotgo.go @@ -858,7 +858,11 @@ func FindBitmap(bit C.MMBitmapRef, args ...interface{}) (int, int) { tolerance = 0.5 } - return internalFindBitmap(bit, sbit, tolerance) + fx, fy := internalFindBitmap(bit, sbit, tolerance) + FreeBitmap(bit) + FreeBitmap(sbit) + + return fx, fy } // FindPic finding the image by path @@ -886,6 +890,8 @@ func FindPic(path string, args ...interface{}) (int, int) { } fx, fy := internalFindBitmap(openbit, sbit, tolerance) + FreeBitmap(openbit) + FreeBitmap(sbit) return fx, fy }