Why ARC is not deallocating memory after popViewController(为什么 ARC 在 popViewController 之后不释放内存)
问题描述
我正在 UINavigationController 中推送和弹出 ViewController.
我正在跟踪我的应用程序的内存消耗.在推送新的 viewController 时,内存消耗逐渐增加,但是当我使用 [self.navigationController popViewControllerAnimated:NO]; 弹出同一个 ViewController 时,内存消耗并没有减少而是保持不变.p>
用户可以多次推送和弹出特定的viewController,这会导致应用程序在RAM中的高内存消耗.
我应该如何优化我的内存消耗?
当您关闭视图控制器(或弹出它)时,如果您没有对它进行任何强指针,它将被释放(该控制器由导航控制器或呈现视图控制器,因此您在创建并推送或呈现它时通常不需要指向它的指针).
如果没有其他强指针会被释放
I'm pushing and popping ViewControllers in UINavigationController.
I'm tracking the memory consumption of my app.
While pushing the new viewController the memory consumption is increasing gradually, but when I'm popping the same ViewController using [self.navigationController popViewControllerAnimated:NO]; the memory consumption does not decrease but the constant.
That particular viewController can be pushed and popped by user many times which can lead the high memory consumption of app in RAM.
What should I do to optimise my memory consumption?
When you dismiss a view controller (or pop it), it will be deallocated if you didn't make any strong pointers to it (that controller is retained by the navigation controller, or the presenting view controller, so you usually don't need to have a pointer to it when you create it and push or present it).
It will be be released if there are no other strong pointers to it
这篇关于为什么 ARC 在 popViewController 之后不释放内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么 ARC 在 popViewController 之后不释放内存
基础教程推荐
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
