错误写法
requestScreenCapture();
sleep(500)
img = captureScreen()
imglj = images.read("/sdcard/脚本/AJ图片/94.jpg");
xy = findImage(img, imglj);
if (xy) {
toastLog(xy.x + "," + xy.y)
} else {
toastLog("没有找到")
}
imglj = images.read("/sdcard/脚本/AJ图片/94.jpg");
xy = findImage(img, imglj);
if (xy) {
toastLog(xy.x + "," + xy.y)
} else {
toastLog("没有找到")
}
imglj.recycle()
上面的写法就会报回收泄露信息第4行代码没有回收,因为第一个读取图片没有回收又再次读取图片造成了泄露。
正确写法
requestScreenCapture();
sleep(500)
img = captureScreen()
img1 = images.read("/sdcard/脚本/AJ图片/1.jpg");
xy = findImage(img, img1);
if (xy) {
toastLog(xy.x + "," + xy.y)
} else {
toastLog("没有找到")
}
img1.recycle()
img2 = images.read("/sdcard/脚本/AJ图片/2.jpg");
xy = findImage(img, img2);
if (xy) {
toastLog(xy.x + "," + xy.y)
} else {
toastLog("没有找到")
}
img2.recycle()
QQ群 568523841