开发者

How can I cleanup AVCaptureSessions created in BarcodePickerController:viewWillAppear in the RedLaser SDK?

Investigation with the allocations performance tool shows that AVCaptureSessions are being allocated and never released in BarcodePickerController:viewWillAppear in the RedLaser SDK.

BarcodePickerController *_barcodeScanner = [[BarcodePickerController alloc] init];

[_barcodeScanner viewDidLoad];

//[_barcodeScanner viewWillAppear:NO]; // Option 1.
//[_barcodeScanner viewDidAppear:NO]; // Option 1.

[_barcodeScanner stopScanning];

for (int i = 0; i < 200; i++) {
    NSLog(@"Run:%d", i);
    //[_barcodeScanner resumeScanning]; // Option 1.
    //[_barcodeScanner stopScanning]; // Option 1.

    [_barcodeScanner viewWillAppear:NO]; // Option 2.
    [_barcodeScanner viewDidAppear:NO];  // Option 2.
    [_barcodeScanner viewWillDisappear:NO]; // Option 2.
    [_barcodeScanner viewDidDisappear:NO]; // Option 2.
}

//[_barcodeScanner viewWillDisappear:NO]; // Option 1.
//[_barcodeScanner viewDidDisappear:NO]; // Option 1.

[_barcodeScanner viewDidUnload];

[_barcodeScanner release];

The background is that I am writing an application with two AVCaptureSessions. One is created and managed by red laser as shown in the above sample code while the other is created by myself manually. I need to use option 2 as shown in the above code rather than option 1 to work around another bug where autofocus stops working in the capture session that is created second (be it my one or red lasers).

The only work around I have found for the autofocus bug is to recreate the capture sessions entirely rather than just starting and stopping them. I can do this with the red laser sdk as shown in option 2 above, but this eventually leads to my app being killed after a certain number of transitions between the sessions and receiving memory warnings. This occurs due to the fact that the AVCaptureSessions are not being clean开发者_如何学Pythoned up.

I don't have any memory warnings or leaks when using option 1.

How can these wayward AVCaptureSessions be cleaned up?


RedLaser technical support have confirmed that this is a bug in their SDK 2.X. Their technical support and myself have confirmed that the bug is fixed in version 3 of the SDK.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜