Learn about leaking view controllers without opening Instruments. See http://holko.pl/2017/06/26/checking-uiviewcontroller-deallocation/
First, import the library using import DeallocationChecker
. Then call dch_checkDeallocation()
from viewDidDisappear(_:)
in your view controllers:
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
dch_checkDeallocation()
}
If a view controller isn’t deallocated after disappearing for good, an assertion inside dch_checkDeallocation(usingDelay:)
will fail:
At this point we can simply open the Memory Graph Debugger to investigate the reason of a cycle.
Add the line pod "DeallocationChecker"
to your Podfile
Add the line github "fastred/DeallocationChecker"
to your Cartfile
Project created by Arek Holko (@arekholko on Twitter).