Use MLeaksFinder for automatic leak detection
masterUIView and UIViewController objects. If a leak is detected, it presents an alert showing the leaked object within its View-ViewController stack.repository·master·Indexed 26 days ago
https://github.com/tencent/mleaksfinderA tool for iOS developers to detect memory leaks in UIView and UIViewController objects. It provides visual alerts for leaks and supports custom object graph monitoring via the MLCheck macro. Integration is available via CocoaPods, with optional support for FBRetainCycleDetector for retain cycle detection.
UIView and UIViewController objects. If a leak is detected, it presents an alert showing the leaked object within its View-ViewController stack.Add MLeaksFinder to your Podfile. MLeaksFinder becomes active immediately after pod install without requiring any additional code or header imports.
pod 'MLeaksFinder'MLeaksFinder does not include FBRetainCycleDetector by default due to licensing. To use it for finding retain cycles, you must manually add FBRetainCycleDetector to your Podfile and enable the MEMORY_LEAKS_FINDER_RETAIN_CYCLE_ENABLED macro in MLeaksFinder.h.
pod 'FBRetainCycleDetector'To extend leak detection to objects other than UIView or UIViewController, override - (BOOL)willDealloc in your class and use the MLCheck macro to inspect specific properties or objects in the graph.
- (BOOL)willDealloc {
if (![super willDealloc]) {
return NO;
}
MLCheck(self.viewModel);
return YES;
}If a class is a singleton or is intentionally designed not to be deallocated, prevent MLeaksFinder from reporting it as a leak by overriding the - (BOOL)willDealloc method and returning NO.
- (BOOL)willDealloc {
return NO;
}