How it works didReceiveMemoryWarning for iOS 6

2019-08-06 19:17发布

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条回答
在下西门庆
2楼-- · 2019-08-06 19:47

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.

查看更多
登录 后发表回答