iOS Swift popViewController未从内存中释放?
我在关闭从uiNavigationController连接并打开的iOS Swift popViewController未从内存中释放?,swift,memory,memory-leaks,Swift,Memory,Memory Leaks,我在关闭从uiNavigationController连接并打开的UIViewcontroller时遇到问题,当我关闭/重新打开BUIViewcontroller时,每次打开它时内存都会增加,但当我关闭它时,内存不会下降 我尝试了以下代码,但都是一样的: DispatchQueue.main.async{[weak self]位于 guard let strongSelf=self-else{return} strongSelf.navigationController?.pushViewCon
UIViewcontroller
时遇到问题,当我关闭/重新打开BUIViewcontroller
时,每次打开它时内存都会增加,但当我关闭它时,内存不会下降
我尝试了以下代码,但都是一样的:
DispatchQueue.main.async{[weak self]位于
guard let strongSelf=self-else{return}
strongSelf.navigationController?.pushViewController(vc,动画:true)
}
及
DispatchQueue.main.async{[unowned self]位于
self.navigationController?.pushViewController(vc,动画:true)
}
及
self.navigationController?.pushViewController(vc,动画:true)
Buiviewcontroller
在情节提要中只有一个图像,没有代码
知道如何从内存中释放关闭的“pop”UIVIewcontroller吗
- 确保没有设置任何指向该viewController的强指针(例如导航控制器),否则该控制器将被导航控制器保留
- 尽量避免对IBOutlets使用强属性
- 如果您在代码中使用self,请确保它是可选的self,使用[weak self]Swift块 如果没有其他指向它的强指针,它将被释放