DeallocationChecker
在不打开Instruments的情况下了解视图控制器泄漏。
使用
首先,通过调用(例如从您的应用程序代理)启用库
#if DEBUG
DeallocationChecker.shared.setup(with: .alert) // There are other options than .alert too!
#endif
然后,在您的视图控制器中,在重写的viewDidDisappear(_:)
内部调用
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
DeallocationChecker.shared.checkDeallocation(of: self)
}
如果某个视图控制器在完全消失后没有释放,您将看到一个有用的警报
此时我们可以简单地打开内存图调试器来调查循环的原因。
安装
CocoaPods
将以下行 pod "DeallocationChecker"
添加到您的 Podfile
Carthage
将以下行 github "fastred/DeallocationChecker"
添加到您的 Cartfile
作者
该项目由 Arek Holko 创建 (@arekholko 在 Twitter 上)