大家好我正在使用Ray提供的rss阅读器,这很棒。该应用程序需要解析一个相当大的xml文件,大约7MB。这个过程运行正常,我可以下载并解析内容并将其保存到数据库中。但是,我的内存存在一个主要问题。当在仪器中运行时,它会上升到大约30mb,虽然它只有30-40秒,但是当我在第一次运行时执行下载和解析时,它会崩溃应用程序。
对此有任何帮助将不胜感激。我认为导致主要问题的代码是:
- (void)requestFinished:(ASIHTTPRequest *)request {
//////// problem code /////////
NSError *error;
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:[request responseData]
options:0 error:&error];
[_queue addOperationWithBlock:^{
if (doc == nil) {
} else {
entries = [NSMutableArray array];
[self parseFeed:doc.rootElement entries:entries];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
for (RSSEntry *entry in entries) {
int insertIdx = [_allEntries indexForInsertingObject:entry sortedUsingBlock:^(id a, id b) {
RSSEntry *entry1 = (RSSEntry *) a;
RSSEntry *entry2 = (RSSEntry *) b;
return [entry1.articleDate compare:entry2.articleDate];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//... do everything I've done before...
[pool drain];
}];
[_allEntries insertObject:entry atIndex:insertIdx];
entries = 0;
}
}];
}
//[doc release];
//doc = nil;
}];
[doc release];
doc = nil;
[error release];
}
答案 0 :(得分:0)