Skip to content

Instantly share code, notes, and snippets.

@hhartz
Last active Oct 12, 2015
Embed
What would you like to do?
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