Skip to content

Find memory leaks in your iOS app at develop time.

Notifications You must be signed in to change notification settings

siperman/MLeaksFinder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MLeaksFinder

MLeaksFinder helps you find memory leaks in your iOS apps at develop time. It can automatically find leaks in UIView and UIViewController objects, hit assertion and print the View-ViewController stack when leaks happening. You can also extend it to find leaks in other kinds of objects.

Installation

  • Download MLeaksFinder
  • Add MLeaksFinder as a subproject
  • Add MLeaksFinder to your Target Dependencies and Link Binary With Libraries
  • Click your app's target, then "Build Settings", search for "Other Linker Flags", add '-ObjC'

Or you can simply copy the source files into your project.

Usage

MLeaksFinder can automatically find leaks in UIView and UIViewController objects. When leaks happening, it will hit assertion and print the leaked object in its View-ViewController stack.

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Possibly Memory Leak.
In case that MyTableViewCell should not be dealloced, override -willDealloc in MyTableViewCell by returning NO.
View-ViewController stack: (
    MyTableViewController,
    UITableView,
    UITableViewWrapperView,
    MyTableViewCell
)'

Mute Assertion

If your class is designed as singleton or for some reason objects of your class should not be dealloced, override -willDealloc in your class by returning NO.

- (BOOL)willDealloc {
    return NO;
}

Find Leaks in Other Objects

MLeaksFinder finds leaks in UIView and UIViewController objects by default. However, you can extend it to find leaks in the whole object graph rooted at a UIViewController object.

- (BOOL)willDealloc {
    if (![super willDealloc]) {
        return NO;
    }
    
    MLCheck(self.viewModel);
    return YES;
}

About

Find memory leaks in your iOS app at develop time.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 100.0%