diff --git a/src/mlkit/mlkit-cameraview.ios.ts b/src/mlkit/mlkit-cameraview.ios.ts index ac44a0fe..59d4fb20 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 { 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; }