The first thing I did was enter the dealloc methods of all the AVCam files. I quickly found that AVCamCaptureManager and AVCamRecorder are not freed when AVCamViewController was. I checked the saved and released calls, and they seemed to be balancing, so I set a breakpoint at the exit [captureManager] and found that it has saveCount from 2 AFTER the release (and therefore dealloc AVCamCaptureManager was not called).
Then I went through the process of creating a capture manager and found that it had a save counter of 3 right after the init method was called.
By executing the init method and checking the amount of hold on each line, I found that the following two lines increase the number of holds:
[self setDeviceConnectedObserver=[notificationCenter addObserverForName:AVCaptureDeviceWasConnectedNotification object:nil queue:nil usingBlock:deviceConnectedBlock]]; [self setDeviceDisconnectedObserver=[notificationCenter addObserverForName:AVCaptureDeviceWasDisconnectedNotification object:nil queue:nil usingBlock:deviceDisconnectedBlock]];
Looking through, I found that the removeObserver copies were INSIDE for the dealloc method for AVCamCaptureManager (which was not called), and therefore the save count never fell to 0.
To fix this, I created a new public removeObservers method:
-(void)removeObservers { NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter removeObserver:[self deviceConnectedObserver]]; [notificationCenter removeObserver:[self deviceConnectedObserver]]; }
and taking the same OUT strings from the dealloc AVCamCaptureManager method.
Call [captureManager removeObservers]; and THEN calling [captureManager release]; in the dealloc method, the AVCamViewController successfully resets the hold value to 0.
Testing with Activity Activity now has a media camera process that sings just 5-17Mb, and the crash stops!
Hope this helps someone else with this issue!
Red nightingale
source share