How it works didReceiveMemoryWarning for iOS 6

故事扮演 提交于 2019-12-11 08:29:01

问题


I don't know too much information about didReceiveMemoryWarning but considering what I read on other posts and looking for in the documentation, I've seen that in case of iOS 5, any non-visible view controller will dump its view, but in case of iOS 6 the documention (documentation says that the default implementation "exits" and I don't know exactly how I should understand that.

I've been doing some tests with the iOS Simulator simulating a low-memory warning, and I appreciate (on iOS 5) that in case I am in a 2nd view on the stack and I simulate a low-memory warning, nothing happens with the present view but if i go back to the previous view was released and the viewDidLoad is called again as I expected, however in case of iOS 6 none of the previous views was released, what I mean with this and this is my question: What are the consequences of a didReceiveMemoryWarning on iOS 6 if the views are not released, should I be worried for anything else that I'm not considering? Even though the views are not released things like the class variables (NSMutableArray for example) could be deallocated?


回答1:


You only have more control as views are no longer purged under low-memory conditions and so this method [viewDidUnload] is never called (Deprecated UIViewController Methods).

If the view is something expensive to build but not as hungry for memory , you'll probably not release it. As far as I know iOs won't release anything in case of memory warning, the decision is completely up to you, use didReceiveMemoryWarning or other notification techniques (see the section Observe Low-Memory Warnings).

WWDC 2012 Session 236: The Evolution of View Controllers on iOS might be interesting for you.



来源:https://stackoverflow.com/questions/15393226/how-it-works-didreceivememorywarning-for-ios-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!