I'm using ZBar reader in my app for scanning QR Code. When I continuously open and close this scanner, the app terminated with message App Terminated due to Memory Pressure
.
I searched over this and got an answer in which the same scenario that my app faces. ie, first time opening the scanner had a 1 second delay, second had a 2 second delay, third had a 5 second delay. and when going for fourth or fifth the app terminated.
But that answer is for UIImagePickerController
. I'm using ZBar reader. Both are somewhat similar. I don't know how to modify my code to solve it.
Here is the code that I'm using,
codeReader = [ZBarReaderViewController new];
codeReader.readerDelegate=self;
codeReader.supportedOrientationsMask = ZBarOrientationMaskAll;
codeReader.showsCameraControls = NO;
codeReader.showsZBarControls=NO;
ZBarImageScanner *scanner = codeReader.scanner;
[scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0];
Class captureDeviceClass = NSClassFromString(@"AVCaptureDevice");
if (captureDeviceClass != nil) {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([device hasTorch] || [device hasFlash]){
[device lockForConfiguration:nil];
[device setTorchMode:AVCaptureTorchModeOff];
[device setFlashMode:AVCaptureFlashModeOff];
[device unlockForConfiguration];
}
}
[self.view.window.rootViewController presentViewController:codeReader animated:YES completion:nil];
codeReader.cameraOverlayView = overlayview;
How should I change it to solve the issue?