I have a PhoneGap app that uses the ZBar scanning plugin in iOS. It allows me to use the scanner a few times, but after a few tries, the next click on the scan button to invoke the plugin causes the app freeze for anywhere between 30 seconds and 5 minutes. Then it will resume normal function again.
It only happens on devices when iOS7 is installed. I have tested this.
I've noticed that xcode gives me an output message of "Received memory warning". It might be related somehow.
Any ideas?
According to this issue, the ZBarReaderViewController
's view
property is retained and therefore leaks.
As stated in the ZBar SDK documentation here, when you initialise the ZBarReaderViewController
set the reader's view property to autorelease
:
- (IBAction) scanButtonTapped
{
// ADD: present a barcode reader that scans from the camera feed
ZBarReaderViewController *reader = [ZBarReaderViewController new];
// Fixes memory leak for the view property.
[reader.view autorelease];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
// TODO: (optional) additional reader configuration here
// EXAMPLE: disable rarely used I2/5 to improve performance
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
// present and release the controller
[self presentModalViewController: reader
animated: YES];
[reader release];
}