The shown memory handling is wrong. Am 13.06.2011 um 16:31 schrieb Bing Li:
> + (NSString *)read:(NSString *)xml Path:(NSString *)xPath This methods signature should be read:path: with a lowercase p. > { > // The Instruments indicated the following line got memory leaks. > The amount of leaked memory was not large (about 400KB) 400 KB is a VERY large amount to leak. > NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithXMLString:xml > options:NSXMLDocumentTidyXML error:NULL]; > > NSArray *nodes = [xmlDoc nodesForXPath:xPath error:NULL]; You hold a pointer to nodes but you do not retain them (usually no problem) > [xmlDoc release]; But here you release xmlDoc which was the only owner of nodes. After this line nodes might be gone. Use autorelease instead. That will keep xmlDoc alive long enough. > if ([nodes count] > 0) This might kill you. > { > return [[nodes objectAtIndex:0] stringValue]; This as well. > } > else > { > return @""; > } > } _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com