I have a super basic AVCaptureSession set up with an AVCaptureVideoDataOutput and AVCaptureStillImageOutput. AVCaptureVideoDataOutput does not have a buffer delegate. There’s nothing fancy going on, just setting up a standard issue AVCaptureSession. If I just compile the app and let it sit there for about 10 minutes, the available memory drops by like 1mb every minute or so. I’ve started the app with 72mb free, and after just letting it sit on my desk, I’ve seen free memory get as low as 33mb.
If I comment out the piece where I add AVCaptureVideoDataOutput to the session, available memory stays around 70-72mb.
So I set up a button to remove AVCaptureVideoDataOutput from the session, and after tapping the button, available memory immediately jumps back up to when the app was first run (~72mb). Has anyone else seen this and know of a workaround? I have iOS 5.0 on my iPhone and the latest beta SDK.
Edit: Here’s the code that adds AVCAptureVideoDataOutput:
...
NSNumber *rgbNum = [NSNumber numberWithInt:kCVPixelFormatType_32BGRA];
NSDictionary *videoSettings = [NSDictionary dictionaryWithObject:rgbNum forKey:(id)kCVPixelBufferPixelFormatTypeKey];
dataOutput = [AVCaptureVideoDataOutput new];
[dataOutput setAlwaysDiscardsLateVideoFrames:YES];
[dataOutput setVideoSettings:videoSettings];
_videoDataOutputQueue = dispatch_queue_create("VideoDataOutputQueue", NULL);
[dataOutput setSampleBufferDelegate:self queue:_videoDataOutputQueue];
dispatch_release(_videoDataOutputQueue);
if ([session canAddOutput:dataOutput]) {
[session addOutput:dataOutput];
} else {
NSLog(@"couldn't add av data output");
}
...
Commenting out the buffer delegate doesn’t seem to make a difference.
Just tried this again and it went from ~70mb free to ~54mb free within 6 minutes. 🙁
Apparently there’s no workaround for this – filed a bug w/ Apple.
Edit:
This question is a bit old, but in case it helps anyone: I’m not 100% positive, but I think the reason I was seeing this is because I had zombie objects turned on! Make sure you don’t have zombie objects enabled in Xcode and see if that helps! Go to “Edit Scheme…” then choose the Diagnostics tab.