I have a memory issue with an iPad app I am working on :
it has only 3 views controllers, and a navigation controller.
I swap view controllers from A to B with a push segue , then to C with a push segue, then to A again with a popToRootViewController instruction.
I have implemented didReceiveMemoryWarning on all the view controllers, just to know what happen :
view B is correctly unload from memory but view C seems to duplicate itself and consumes memory !
When I trig a memory warning, I can see severals view C answering…
It don’t look like circular retain because I declared all my parents reference as weak, and because the leak instruments doesn’t detect any leaks, nor retain cycles, but memory increase.
and this cause crash when testing with a real iPad.
what can I do ? where can I look at ?
Is it possible to ask the navigation controllers to release all its previous object but the current on-screen one ?
edit :
in view didload, I have added some observers as below :
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
[dnc addObserver:self selector:@selector(undoManagerDidUndo:) name:NSUndoManagerDidUndoChangeNotification object:undoManager];
[dnc addObserver:self selector:@selector(undoManagerDidRedo:) name:NSUndoManagerDidRedoChangeNotification object:undoManager];
is it possible that doing this make that dnc keeps a retain reference to self somewhere ?
You don’t have to nil them if you are using ARC. ARC should automatically release them once there is no longer a strong pointer to them. I don’t know of a way to see which one is retaining it. There probably is but I have looked and can’t find a way. You should remove all GestureRecognizers and anything else so that it will dealloc.