From 617ecde4f2d466d36c22a5d49bfbacd98dde02da Mon Sep 17 00:00:00 2001 From: Andriyanov Nikita Date: Fri, 28 May 2021 10:20:33 +0300 Subject: [PATCH 1/3] Release context to avoid leak --- .../ios_lib/TNSMLKitCamera/TNSMLKitCamera/TNSMLKitCameraView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/ios_lib/TNSMLKitCamera/TNSMLKitCamera/TNSMLKitCameraView.m b/src/platforms/ios_lib/TNSMLKitCamera/TNSMLKitCamera/TNSMLKitCameraView.m index b10ffad5..f0dab9f9 100755 --- a/src/platforms/ios_lib/TNSMLKitCamera/TNSMLKitCamera/TNSMLKitCameraView.m +++ b/src/platforms/ios_lib/TNSMLKitCamera/TNSMLKitCamera/TNSMLKitCameraView.m @@ -65,7 +65,7 @@ + (NSMutableData * _Nullable)getInputData:(nonnull UIImage *)img withRows:(int) } } } - + CGContextRelease(context); return inputData; } From 113bbb0ee15f4685074865493ef4726c2654033b Mon Sep 17 00:00:00 2001 From: Andriyanov Nikita Date: Fri, 28 May 2021 10:25:25 +0300 Subject: [PATCH 2/3] One more leak fix --- src/mlkit/mlkit-cameraview.ios.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mlkit/mlkit-cameraview.ios.ts b/src/mlkit/mlkit-cameraview.ios.ts index ac44a0fe..206317ed 100644 --- a/src/mlkit/mlkit-cameraview.ios.ts +++ b/src/mlkit/mlkit-cameraview.ios.ts @@ -238,6 +238,11 @@ class TNSMLKitCameraViewDelegateImpl extends NSObject implements TNSMLKitCameraV } else { this.owner.get().runDetector(image, onComplete); } + image = null; + // FIX: possible memory issue when picking images many times. + // Not the best solution, but the only one working for now + // https://github.com/NativeScript/nativescript-imagepicker/issues/222 + setTimeout(Utils.GC, 200); } private uiImageToFIRVisionImage(image: UIImage): FIRVisionImage { From 95322aaf63f5719a5e814dd23eb5bf3e26130fe2 Mon Sep 17 00:00:00 2001 From: Andriyanov Nikita Date: Fri, 28 May 2021 10:26:41 +0300 Subject: [PATCH 3/3] Fix spaces --- src/mlkit/mlkit-cameraview.ios.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mlkit/mlkit-cameraview.ios.ts b/src/mlkit/mlkit-cameraview.ios.ts index 206317ed..59d4fb20 100644 --- a/src/mlkit/mlkit-cameraview.ios.ts +++ b/src/mlkit/mlkit-cameraview.ios.ts @@ -239,10 +239,10 @@ class TNSMLKitCameraViewDelegateImpl extends NSObject implements TNSMLKitCameraV this.owner.get().runDetector(image, onComplete); } image = null; - // FIX: possible memory issue when picking images many times. - // Not the best solution, but the only one working for now - // https://github.com/NativeScript/nativescript-imagepicker/issues/222 - setTimeout(Utils.GC, 200); + // FIX: possible memory issue when picking images many times. + // Not the best solution, but the only one working for now + // https://github.com/NativeScript/nativescript-imagepicker/issues/222 + setTimeout(Utils.GC, 200); } private uiImageToFIRVisionImage(image: UIImage): FIRVisionImage {