Ios5 在ios 5.1(带ARC)中将视频转换为帧时内存不足的应用程序崩溃

Ios5 在ios 5.1(带ARC)中将视频转换为帧时内存不足的应用程序崩溃,ios5,automatic-ref-counting,avfoundation,video-capture,Ios5,Automatic Ref Counting,Avfoundation,Video Capture,我使用AVFoundation拍摄了视频,当我试图将拍摄的视频转换为帧时,我的应用程序因内存不足而崩溃。我正在使用ios 5.1和ARC启用的项目 我的代码如下: -(void) makeVideoCall { videoOutput = [[AVCaptureVideoDataOutput alloc]init]; [captureSession addOutput:videoOutput]; videoOutput.videoSettings = [NSDic

我使用AVFoundation拍摄了视频,当我试图将拍摄的视频转换为帧时,我的应用程序因内存不足而崩溃。我正在使用ios 5.1和ARC启用的项目

我的代码如下:

-(void) makeVideoCall
{
    videoOutput = [[AVCaptureVideoDataOutput alloc]init];
    [captureSession addOutput:videoOutput];
    videoOutput.videoSettings =
    [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA]
                                forKey:(id)kCVPixelBufferPixelFormatTypeKey];
    videoOutput.alwaysDiscardsLateVideoFrames = YES;
    dispatch_queue_t queue = dispatch_queue_create("MyQueue", NULL);
    [videoOutput setSampleBufferDelegate:self queue:queue];
    dispatch_release(queue);

    [videoOutput setSampleBufferDelegate:self queue:queue];
    [captureSession startRunning];
}

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{
    NSLog(@"\n Inside CaptureOutput....");

    CGImageRef tempImage = [self imageRefFromSampleBuffer:sampleBuffer];
    image = [[UIImage alloc] initWithCGImage:tempImage scale:0.2 orientation:UIImageOrientationLeftMirrored];
}

-(CGImageRef)imageRefFromSampleBuffer:(CMSampleBufferRef)sampleBuffer {

    CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); 
    CVPixelBufferLockBaseAddress(imageBuffer,0); 
    uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(imageBuffer); 
    size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer); 
    size_t width = CVPixelBufferGetWidth(imageBuffer); 
    size_t height = CVPixelBufferGetHeight(imageBuffer); 

    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 
    CGContextRef context = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, colorSpace, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst); 
    CGImageRef newImage = CGBitmapContextCreateImage(context); 
    CVPixelBufferUnlockBaseAddress(imageBuffer,0);
    CGContextRelease(context); 
    CGColorSpaceRelease(colorSpace);
    return newImage;

}
任何人请告诉我该怎么做

问候,,
Monish.

您可能需要使用CFRelease(cgimagerf)来释放cgimagerf对象。
您可以转到Xcode并在产品栏中单击分析。它将帮助您分析代码,并可能导致内存泄漏。

您可能需要使用CFRelease(cgimagerf)来释放cgimagerf对象。 您可以转到Xcode并在产品栏中单击分析。它将帮助您分析代码,并可能导致内存泄漏