50

GitHub - fastred/DeallocationChecker: Catch leaking view controllers without ope...

 5 years ago
source link: https://github.com/fastred/DeallocationChecker
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

DeallocationChecker

Learn about leaking view controllers without opening Instruments.

Usage

First, enable the library by calling (for example from your application delegate):

#if DEBUG
    DeallocationChecker.shared.setup(with: .alert) // There are other options than .alert too!
#endif

Then, in your view controllers from within viewDidDisappear(_:) override, call:

override func viewDidDisappear(_ animated: Bool) {
    super.viewDidDisappear(animated)

    DeallocationChecker.shared.checkDeallocation(of: self)
}

If a view controller isn’t deallocated after disappearing for good, you'll see a helpful alert:

Leaked view controller demo

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).


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK