문제

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];
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top