当我们在自动发布池中使用NSXmlParser时内存泄漏

时间:2012-04-03 09:17:09

标签: iphone objective-c nsxmlparser

- (void)main
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    self.workingArray = [NSMutableArray array];
    self.descriptionString = [NSMutableString string];

    NSXMLParser *parser = [[[NSXMLParser alloc] initWithData:dataToParse] autorelease];
    [parser setDelegate:self];
    [parser parse];

    if (![self isCancelled])
    {
        // notify our AppDelegate that the parsing is complete
        [self.delegate didFinishParsing:self.workingArray];
    }

    self.workingArray = nil;
    self.descriptionString = nil;
    self.dataToParse = nil;
    [pool drain];
}

在此代码中,当我们在此行中调用[parser parse]时,会发生内存泄漏问题。

0 个答案:

没有答案