Simple memory leak checker based on weak reference examination
LeakChecker
Simple memory leak checker based on weak reference examination.
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Installation
LeakChecker is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'LeakChecker'
For systems without UIKit (tvOS, macOS) you can use core functionality with your own UI or just console logging:
pod 'LeakChecker', :subspecs => ['Core']
Usage
- 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)
}
Author
Max Sol, maxoldev@gmail.com
License
LeakChecker is available under the MIT license. See the LICENSE file for more info.
Leak icons created by Smashicons – Flaticon