gpt4 book ai didi

iphone - didReceiveMemoryWarning 什么时候实际调用

转载 作者:可可西里 更新时间:2023-11-01 04:21:33 24 4
gpt4 key购买 nike

我从来没有亲眼见过 didReceiveMemoryWarning 调用过。调用时是否存在已知的内存使用阈值?

最佳答案

当系统内存不足时调用它,然后您需要清除您的UIViewController

您可以在模拟器中模拟内存警告:Hardware > Simulate Memory Warning 看看会发生什么。

如果您支持 iOS6 之前的版本,请务必注意 Apple's documentation 中的以下内容:

Prior to iOS 6, when a low-memory warning occurred, the UIViewController class purged its views if it knew it could reload or recreate them again later. If this happens, it also calls the viewWillUnload and viewDidUnload methods to give your code a chance to relinquish ownership of any objects that are associated with your view hierarchy, including objects loaded from the nib file, objects created in your viewDidLoad method, and objects created lazily at runtime and added to the view hierarchy. On iOS 6, views are never purged and these methods are never called. If your view controller needs to perform specific tasks when memory is low, it should override the didReceiveMemoryWarning method.

关于阈值,我尽量不要超过12MB内存。

关于iphone - didReceiveMemoryWarning 什么时候实际调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12968879/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com