3

I'm experiencing a wierd behavior in the new AVFoundation classes in the iPhone SDK.

I have a AVCaptureStillImageOutput for taking pictures, and I am setting its outputSettings to my liking. The code follows:

 AVCaptureStillImageOutput *stillImageOutput = [[[AVCaptureStillImageOutput alloc] init] autorelease];
[stillImageOutput setOutputSettings:[NSDictionary dictionaryWithObject:AVVideoCodecJPEG forKey:AVVideoCodecKey]];
[self setStillImageOutput:stillImageOutput];

(stillImageOutput property is defined as "retain")

I stumbled upon a leak in leaks, with 100% of the leak fault on the setOutputSettings line. I believe that I confine to the memory management guidelines in the code attached, still it is leaking.

My solution was to

[self.stillImageOutput setOutputSettings:nil];

in the dealloc, just before

[self setStillImageOutput:nil];

The leak indeed stopped, but it looks weird. Shouldn't the releasing of stillImageOutput release its outputSettings property as well?

Anyway, if someone else runs into this, thought I should share my solution.

Cheers!
Oded.

Oded Ben Dov
  • 9,936
  • 6
  • 38
  • 53

1 Answers1

0

Yes, the releasing of stillImageOutput should release it's outputSettings property as well. Either it's an Apple bug (should let them know, your use case is pretty simple) or remove your line, and see whether anything other than your class is hanging onto that stillImageOutput object (which is holding the outputSettings).

Scott Corscadden
  • 2,831
  • 1
  • 25
  • 43