現在、JSON からすべてのデータを解析し、配列に格納しています。ただし、解析を開始すると、メモリ使用量が約 25mb から 800mb に跳ね上がります。いくつかの調査を行った後、 @autoreleasepool を GCD ブロックに入れるように言われましたが、役に立ちませんでした。
これまでに得たコードは次のとおりです。
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];
});
});
TouchJSON を使用してデータを解析しています。
さらに調査したところ、これは、一度解析されたすべての値を、各オブジェクトをメモリに保持する NSArray に格納しているという事実と関係があると思います。CoreData などを使用する必要があると考えています。