I'm currently parsing all of my data from JSON and storing it in an array. However when it starts parsing the memory usage jumps up from about 25mb to 800mb. After doing some research I was told to put an @autoreleasepool in the GCD block but to no avail.
Here's the code I've got so far:
self.channelSchedules = [NSMutableArray new];
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Add code here to do background processing
//Loop through each channel object and download schedule
@autoreleasepool {
for (atlas_channel* channel in self.channels) {
NSLog(@"Updating listings for %@", [channel getChannelTitle]);
[self.channelSchedules addObject:[[channel getChannelSchedule] returnCurrentContentObject]];
[self.tableView reloadData];
[self scrollViewDidScroll:nil];
}
}
dispatch_async( dispatch_get_main_queue(), ^{
// Add code here to update the UI/send notifications based on the
// results of the background processing
[self.tableView reloadData];
});
});
I'm using TouchJSON to parse the data.
Upon further research I think this has something to do with the fact that I'm storing all values once parsed into an NSArray which retains each object in memory. I'm thinking I'll have to use CoreData or something along those lines.