Skip to content

Instantly share code, notes, and snippets.

@hhartz
Last active October 12, 2015 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hhartz/4044503 to your computer and use it in GitHub Desktop.
Save hhartz/4044503 to your computer and use it in GitHub Desktop.
Manual tracking of retain/release and subsequent retainCount
- (NSString*) filteredCallstackSymbol
{
NSArray *callStackSymbols = [NSThread callStackSymbols];
NSPredicate *filter = [NSPredicate predicateWithFormat:@"self contains 'Stay'"]; // filter for 'ClassPrefix'
NSArray *filtered = [callStackSymbols filteredArrayUsingPredicate:filter];
NSString *closestSymbol = [filtered objectAtIndex:(filtered.count>2)? 2 : 1];
return closestSymbol;
}
-(id) retain
{
id ret = [super retain];
NSLog(@"retain: %ld %@",
(long)[self retainCount],
[self filteredCallstackSymbol]);
return ret;
}
-(oneway void) release
{
[super release];
NSLog(@"release: %ld %@",
(long)[self retainCount],
[self filteredCallstackSymbol]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment