• Stars
    star
    116
  • Rank 303,805 (Top 6 %)
  • Language
    Objective-C
  • License
    Other
  • Created about 12 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple and easy tool to discover View Controllers that are not being deallocated when you expect them to.

THIS PROJECT IS DEPRECATED. CHECK OUT THE NEW, MORE GENERIC MSLeakHunter

MSVCLeakHunter

Simple and easy tool to discover View Controllers that are not being deallocated when you expect them to.

This is very common with retain cycles using blocks, and it's very tricky sometimes to realize that some view controller is never getting deallocated, because they don't show up as leaks when using Instruments.

Installation

  • Add MSVCLeakHunter.h and MSVCLeakHunter.m to the Xcode project.
  • Place a call to +[MSVCLeakHunter install] somewhere during app initialization (e.g. the applicationDidFinishLaunchingWithOptions: method of your app delegate.)
  • Make sure MSVCLeakHunter_ENABLED is set to 1 in MSVCLeakHunter.h

Or install via Cocoapods: pod 'MSVCLeakHunter'

What it looks like

  • When you run the app with MSVCLeakHunter enabled, and it finds a possible view controller that is leaking, this is what you'll see:

*screenshot from the sample project*

Compatibility

  • MSVCLeakHunter is compatible with ARC and non-ARC projects.

How it works

If you look at the implementation in MSVCLeakHunter.m, it's very naive. All it does is swizzle some methods for every UIViewController instance to discover when a view controller disappear from screen (it gets a viewDidDisappear: call), but isn't deallocated after a certain period of time.

If this happens, it doesn't guarantee 100% that the view controller leaked. For example, if it's inside a UITabBarController, it may disapepar when you select another tab, but it's still retained by the tabbar, and it hasn't leaked.

But it will help you discover, for example, view controllers that you push onto a navigation controller stack, and aren't deallocated when you pop them tapping on the back button.

In the case where you have something like a navigation controller that is shown modally, and then the whole stack goes away when the modal is closed, you may want to tweak the value of kMSVCLeakHunterDisappearAndDeallocateMaxInterval (see MSVCLeakHunter.h) to give MSVCLeakHunter enough margin to avoid a false positive. Otherwise, you may see a log for a possible leak of the controllers at the bottom of the stack if the modal takes longer to be closed.

License

Copyright 2012 MindSnacks

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

MSWeakTimer

Thread-safe NSTimer alternative that doesn't retain the target and supports being used with GCD queues.
Objective-C
971
star
2

MSLeakHunter

Series of tools to help you find and debug objects that are leaking / over-released in your iOS apps.
Objective-C
366
star
3

MSCachedAsyncViewDrawing

Helper class that allows you to draw views (a)synchronously to a UIImage with caching for great performance.
Objective-C
277
star
4

MSPageViewController

Create UIPageViewControllers using only storyboards
Objective-C
89
star
5

MSActiveConfig

Remote configuration and A/B Testing framework for iOS
Objective-C
79
star
6

Zinc

Asset distribution system for mobile clients.
Python
40
star
7

MSEmojiChecksumCalculator

Calculate checksums that are human readable and fun!
Objective-C
29
star
8

MSSidebarController

Fully customizable sidebar controller
Objective-C
27
star
9

MSSpec

Kiwi Spec with support to inject mocks using Objection
Objective-C
22
star
10

Zinc-ObjC

Objective-C client for Zinc asset distribution system
Objective-C
17
star
11

provtool

Command line utility for working with Provisioning Profiles
Python
12
star
12

UIImage-MSImageNamed568hSupport

Method for UIImage to be able to load images with the -568h prefix on the iPhone5.
Objective-C
12
star
13

django-versionfield

A DB Independent Custom Field for storing Version numbers for fast indexing
Python
8
star
14

MSWeakMutableSet

Behaves exactly like an NSMutableSet, but doesn't retain the objects.
Objective-C
8
star
15

penmanship

A simple Gradle plug-in that makes it easy to convert Markdown documents into native Android layout XML files.
Java
7
star
16

JavaZinc

Zinc client in Java
Java
6
star
17

pngnq-mac

Mac OSX build of the pngnq image quantizer with some command line modifications
C
5
star
18

iso8601parser

This is a "fork" of https://github.com/square/iso8601parser but the source has disappeared
Objective-C
3
star
19

django-piston

This is my fork of django-piston by jespern that fixes the following bugs: #171, #84, #169
Python
1
star
20

mindsnacks.github.com

1
star