Skip to content

Instantly share code, notes, and snippets.

@gnachman
Last active April 14, 2016 20:59
Show Gist options
  • Save gnachman/88360e91021283d3f7be to your computer and use it in GitHub Desktop.
Save gnachman/88360e91021283d3f7be to your computer and use it in GitHub Desktop.
Retain release debugging
- (id)retain {
if (_debug) {
NSLog(@"retain %@ rc->%d", self, (int)self.retainCount + 1);
NSLog(@"%@", [NSThread callStackSymbols]);
}
return [super retain];
}
- (oneway void)release {
if (_debug) {
NSLog(@"release %@ rc->%d", self, (int)self.retainCount - 1);
NSLog(@"%@", [NSThread callStackSymbols]);
}
[super release];
}
- (id)autorelease {
if (_debug) {
NSLog(@"autorelease %@", self);
NSLog(@"%@", [NSThread callStackSymbols]);
}
return [super autorelease];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment