I just discovered the Build > Analyze feature of XCode today so I am trying to go through and address all the errors it is finding. There are a few lines XCode finds exception with that are confusing me:
//Test View
self.imageViewTest = [[UIImageView alloc] init];
self.imageViewTest.frame = CGRectMake(0, 0, 100, 100); // <=== Leak
[self.view addSubview:self.imageViewTest];
//Test View 2
self.imageViewTestB = [[UIImageView alloc] init];
self.imageViewTestB.frame = CGRectMake(0, 100, 100, 100); // <=== Leak
[self.view addSubview:self.imageViewTestB];
and later in my setup of video capture
self.captureOutput = [[AVCaptureVideoDataOutput alloc] init];
captureOutput.alwaysDiscardsLateVideoFrames = YES; // <=== Leak
The warning at each of these lines is “Potential leak of an object”. All 3 of these objects are sent the release message in my dealloc method. What could be wrong here?
Thanks!
If you are not using ARC and your properties are setup with the retain attribute, then yes, these are leaks. This line:
should be:
or:
Or better yet, use ARC. It makes things SO much easier.