它如何工作didReceiveMemoryWarning for iOS 6 [英] How it works didReceiveMemoryWarning for iOS 6
问题描述
我不知道有关 didReceiveMemoryWarning
的太多信息,但考虑到我在其他帖子上阅读并在文档中查找,我已经看到了iOS的情况5,任何不可见的视图控制器都会转储其视图,但是对于iOS 6的文档(文档说默认实现退出,我不知道我应该如何理解。
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我一直在用模拟低内存警告的iOS模拟器做一些测试,我很感激(在iOS 5上),如果我在堆栈的第二个视图中并模拟低内存警告,则没有任何反应目前的观点,但如果我回到上一个视图发布,并再次按照我的预期调用viewDidLoad,但是在iOS 6的情况下,之前的观点都没有发布,我mea n,这是我的问题:如果视图没有发布,iOS 6上的 didReceiveMemoryWarning
会有什么后果,我是否应该担心其他任何问题?不考虑?即使视图未发布,类变量(例如NSMutableArray)也可以解除分配?
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?
推荐答案
你只有更多在低内存条件下不再清除控制为的视图,因此永远不会调用此方法[viewDidUnload]
(不推荐的UIViewController方法)。
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).
如果视图构建起来很昂贵但对内存不那么饥饿,那么你可能不会发布它。据我所知,在内存警告的情况下iO不会发布任何内容,决定完全取决于你,使用 didReceiveMemoryWarning
或其他通知技术(参见观察低内存警告。
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会话236:iOS上视图控制器的演变可能对你有用。
这篇关于它如何工作didReceiveMemoryWarning for iOS 6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!