iphone - NSXMLParser Memory Leak from Second Parse Call -
update: while leaks instrument points first call [parser parse];
, have identified leak occurs when make call second time. don't see in nsxmlparser class reference or documentation indicates 1 can't re-parse. missing something? should create new nsxmlparser each time wish parse document?
i trying track down leak in xml parsing code iphone app. i've searched through other posts on leaks nsxmlparser, haven't found answers use, appreciate help.
the instruments leaks tool detecting leak in following code:
nsdata* data = [nsdata datawithcontentsoffile: [[nsbundle mainbundle] pathforresource: @"collisiongraph" oftype: @"graphml"]]; nsxmlparser* parser = [[[nsxmlparser alloc] initwithdata: data] autorelease]; [parser setdelegate:self]; [parser parse]; <<<<< leak here according leaks self.currentpass++; ... [parser parse]; self.currentpass++;
i removed of code delegate callback methods, didn't stop leak.
-(void)parser:(nsxmlparser *)parser didstartelement:(nsstring *)elementname namespaceuri:(nsstring *)namespaceuri qualifiedname:(nsstring *)qualifiedname attributes:(nsdictionary *)attributedict { } -(void)parser:(nsxmlparser *)parser foundcharacters:(nsstring *)string { } -(void)parser:(nsxmlparser *)parser didendelement:(nsstring *)elementname namespaceuri:(nsstring *)namespaceuri qualifiedname:(nsstring *)qname { }
here view in instruments http://i22.photobucket.com/albums/b311/erithil/parserleak.png (linked because don't have rep post images).
i'm stumped this, suggestions appreciated. in advance.
it leak within nsxmlparser (if e.g. xmlcleanupparser() not called on underlying libxml) or reusable memory mistakenly flagged leak. think it's typically happens parsers due them reusing (and not releasing?) allocated memory.
Comments
Post a Comment