/DeallocationChecker

Catch leaking view controllers without opening Instruments.

Primary LanguageSwiftMIT LicenseMIT

DeallocationChecker

Learn about leaking view controllers without opening Instruments. See http://holko.pl/2017/06/26/checking-uiviewcontroller-deallocation/

Usage

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:

Failed assertion

At this point we can simply open the Memory Graph Debugger to investigate the reason of a cycle.

Installation

CocoaPods

Add the line pod "DeallocationChecker" to your Podfile

Carthage

Add the line github "fastred/DeallocationChecker" to your Cartfile

Author

Project created by Arek Holko (@arekholko on Twitter).