Wrapping up my first project using ARC. Imagine my surprise then, to discover a leak almost immediately. Does anyone have any insight as to why the following code would leak with symbol identifier: ‘dispatch_queue_create’:
This is using an overly simplified TWRequest handler in iOS5 w/ ARC:
- (void)loadSomeTweets
{
NSString *queryString = [NSString stringWithString:@"http://search.twitter.com/search.json?"];
NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:@"%23WatchingTheVoice", @"q", nil];
NSURL *targetedSearchURL = [NSURL URLWithString:queryString];
TWRequest *targetedRequest = [[TWRequest alloc] initWithURL:targetedSearchURL
parameters:parameters
requestMethod:TWRequestMethodGET];
[targetedRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
//Do something
}];
}
Why does this leak? The call stack implicates the performRequestWithHandler, but the leak occurs regardless of what I do within the callback handler, even an empty implementation (as shown here) produces the leak. The leak occurs on the simulator and devices.
This problem is the result of a memory leak in Apple’s Twitter framework.