I'd like to learn about memory management in Objective-C which I find not that easy because I'm fairly new at Objective-C and ARC and I'm mostly used to script languages for which I don't have to deal that much (or not at all) with memory management.
The app I'm working on is presenting a viewController (with xib file attached) from code after the press of a button. In this view controller I have several views instantiated; I record a sequence of images (photo's from the camera, saved to disk) which I convert to a movie and I have a gps tracker (mapKit) which display's a little map on screen. After all is done I can push a 'done' button which calls [self dismissViewControllerAnimated:YES completion:nil];
The viewController is animated back to my rootViewController and because I put an NSLog
message inside the dealloc
method in the viewController that is being dismissed I can confirm this viewController is being deallocated.
The problem is that I see the memory rise after the use of the app (usage consists of taking pictures and recording gps locations on a MapKit map as well as generate a movie file) to about 80 MB and this drops to about 70MB when I press 'done' so the viewController dismisses and the app returns to my rootViewController. I can present the same viewController again, use it and dismiss it, and the app will still occupy around 70MB of memory which doesn't drop. This does not really look like a memory leak to me because in that case I would expect a steady rise of memory with every instantiation and dismissal of the viewController. This isn't the case even if I have different buttons in my rootViewController which all instantiate a new and unique instance of my viewController class.
I am wondering: Is there something I should look for or is this expected behavior? Maybe the app is caching classes for future use? With memory management done right, should I be expecting an app to revert to 'virgin' memory state (in this case this would be around 4 MB) after dismissal of the only viewController that was presented?