每次我启动AVCaptureSession时都会收到内存警告,导致一段时间后崩溃.
我正在异步启动会话,而Instruments工具说该应用程序消耗大约2 MB的内存.你知道如何克服这个问题吗?2MB分配的内存太多了吗?
Thankx![iOS 4.3,ARC]
@autoreleasepool {
//Init capture session
session = [[AVCaptureSession alloc] init];
session.sessionPreset = AVCaptureSessionPresetPhoto;
//Resize container view
CGRect cameraContainerFrame = cameraContainerView.frame;
cameraContainerFrame.size = CGSizeMake(320, 426);
cameraContainerView.frame = cameraContainerFrame;
CALayer *viewLayer = [cameraContainerView layer];
[viewLayer setMasksToBounds:YES];
//Create preview layer
captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
CGRect bounds = [cameraContainerView bounds];
[captureVideoPreviewLayer setFrame:bounds];
if ([captureVideoPreviewLayer isOrientationSupported]) {
[captureVideoPreviewLayer setOrientation:AVCaptureVideoOrientationPortrait];
}
[captureVideoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
[viewLayer addSublayer:captureVideoPreviewLayer];
//Get input device
captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([captureDevice lockForConfiguration:nil]){
captureDevice.focusMode = AVCaptureFocusModeContinuousAutoFocus;
captureDevice.whiteBalanceMode = …Run Code Online (Sandbox Code Playgroud)