为什么ARC在popViewController之后没有取消分配内存 [英] Why ARC is not deallocating memory after popViewController

查看:209
本文介绍了为什么ARC在popViewController之后没有取消分配内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在UINavigationController中推送和弹出ViewController.

I'm pushing and popping ViewControllers in UINavigationController.

我正在跟踪应用程序的内存消耗. 推送新的viewController时,内存消耗逐渐增加,但是当我使用[self.navigationController popViewControllerAnimated:NO];弹出相同的ViewController时,内存消耗不会减少,但会保持不变.

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.

该特定的viewController可以被用户多次推送和弹出,这可能导致应用程序在RAM中消耗大量内存.

That particular viewController can be pushed and popped by user many times which can lead the high memory consumption of app in RAM.

我该怎么做才能优化内存消耗?

推荐答案

关闭视图控制器(或将其弹出)时,如果您没有对它进行任何强力指针(该控制器保留在导航控制器或呈现视图控制器,因此创建和推送或呈现时通常不需要指向它的指针.

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之后没有取消分配内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆