简体   繁体   English

ViewController未从内存释放

[英]ViewController not released from Memory

I have this view hierarchy 我有这个视图层次

  • RouterDashboardViewController : RootViewController RouterDashboardViewController:RootViewController

  • RootViewController : UIViewController RootViewController:UIViewController

Currently, RouterDashboardViewController instance is in the navigation stack. 当前,RouterDashboardViewController实例在导航堆栈中。 When I reset rootViewController of NavigationController then RouerDashboardInstance still exist in memory because I can check my deinit{} method not gets called.Below are the stack traces in Instruments but am not able to detect any reason why my RouterDashboard instance not get deallocated. 当我重置NavigationController的rootViewController时,由于可以检查我的deinit{}方法没有被调用,因此RouerDashboardInstance仍然存在于内存中。下面是Instruments中的堆栈跟踪,但无法检测到我的RouterDashboard实例未释放的任何原因。 I am sure there will be retain cycles which keeps RouterDashboard instance still alive. 我确信会有保留周期,使RouterDashboard实例保持活动状态。 One more thing am not understanding these stack traces because ViewDidLoad() method called several times. 还有一件事是不了解这些堆栈跟踪信息,因为ViewDidLoad()方法被调用了几次。 仪器的堆栈痕迹

Something has a strong reference to RouterDashboardViewController . 某些东西对RouterDashboardViewController有很强的参考RouterDashboardViewController A few things to check… 需要检查的几件事...

  • Are you assigning it to a variable? 您是否将其分配给变量?

    • You may need to declare it as weak var … 您可能需要将其声明为weak var …
  • Is it a delegate of another class? 是另一堂课的代表吗?

    • Make sure delegate properties are also weak var s 确保委托属性也为weak var
  • Does it use any closures that refer it self ? 它是否使用任何引用self闭包?

    • Add a capture list to your closure's parameter list ( [unowned self] or [weak self] ) 将捕获列表添加到闭包的参数列表中( [unowned self][weak self]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM