Simple memory leak checker based on weak reference examination.
To run the example project, clone the repo, and run pod install
from the Example directory first.
LeakChecker is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'LeakChecker'
- Activate
LeakChecker.isEnabled = true
(eg fromAppDelegate.init
) - Use built-in handler
DefaultLeakDetectedHandler.isEnabled = true
or handle notificationNSNotification.Name.LeakChecker.leakDetected
by yourself - Add calls
checkLeak(of:)
for all objects may be accidentially retained before their expected deallocation
class YourViewController: UIViewController {
private var viewModel = ViewModel()
deinit {
checkLeak(of: viewModel)
}
Max Sol, maxoldev@gmail.com
LeakChecker is available under the MIT license. See the LICENSE file for more info.