Background: I have a tab bar controller which currently contains 4 tabs. 3 of the tabs are navigation controllers which display a hierarchy of table views for viewing, editing, and creating data. The data is generally NSStrings that are taken from the user and stored in a global variable (data needs to be accessed from multiple views in the hierarchy, as well as multiple tabs).
Problem I have noticed that my app uses quite a bit of memory as soon as it starts (~11mb). However, as I scroll through the table views and use the nav controller to access more table views and edit some data, the memory usage quickly goes up to nearly 20mb. The worst part is that popping out of the detail view controllers does not cause the memory usage to decrease. It will hover around 20-21mb, and if I repeat the process I seem to get higher and higher memory usage. I have tested my app in Leaks and I have solved all issues there. I suspect that my inactive view controllers are still sitting in memory, even as they are not currently displayed. Is there any way to release unneeded view controllers in a navigation controller's hierarchy, or even the inactive view controllers from the tab bar? I have been reading Apple's docs and they strongly suggest implementing didReceiveMemoryWarning:
and applicationDidReceiveMemoryWarning:
in view controllers and the app delegate alike. I really don't know where to start with those methods. What controllers can I release and how do they get recreated? I assume that I'm responsible for that, but I would like to be sure.
Note that I have not yet gotten my app to terminate due to low memory usage, but enough repititions of data entry (lot of view controller pushing and popping) will cause it to slow to a crawl.