https://github.com/fastred/deallocationchecker
Catch leaking view controllers without opening Instruments.
https://github.com/fastred/deallocationchecker
Last synced: over 1 year ago
JSON representation
Catch leaking view controllers without opening Instruments.
- Host: GitHub
- URL: https://github.com/fastred/deallocationchecker
- Owner: fastred
- License: mit
- Created: 2017-06-25T20:58:15.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-06-28T16:44:57.000Z (about 4 years ago)
- Last Synced: 2025-03-28T06:07:00.515Z (over 1 year ago)
- Language: Swift
- Homepage: http://holko.pl/2017/06/26/checking-uiviewcontroller-deallocation/
- Size: 653 KB
- Stars: 803
- Watchers: 10
- Forks: 29
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DeallocationChecker
Learn about leaking view controllers without opening Instruments.
[](https://travis-ci.com/fastred/DeallocationChecker)
## Usage
First, enable the library by calling (for example from your application delegate):
```swift
#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:
```swift
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:

At this point we can simply open the [Memory Graph Debugger](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/special_debugging_workflows.html#//apple_ref/doc/uid/TP40015022-CH9-DontLinkElementID_1) 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](http://holko.pl) ([@arekholko](https://twitter.com/arekholko) on Twitter).