iOS Swift popViewController未从内存中释放?

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

我在关闭从uiNavigationController连接并打开的
UIViewcontroller
时遇到问题,当我关闭/重新打开B
UIViewcontroller
时,每次打开它时内存都会增加,但当我关闭它时,内存不会下降

我尝试了以下代码,但都是一样的:

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)
B
uiviewcontroller
在情节提要中只有一个图像,没有代码

知道如何从内存中释放关闭的“pop”UIVIewcontroller吗

  • 确保没有设置任何指向该viewController的强指针(例如导航控制器),否则该控制器将被导航控制器保留
  • 尽量避免对IBOutlets使用强属性

  • 如果您在代码中使用self,请确保它是可选的self,使用[weak self]Swift块 如果没有其他指向它的强指针,它将被释放


请提供示例项目或更多代码,因为您的示例都做相同的事情,它们本身无法创建内存周期。如何获得UIViewController在这里很重要。