Memory leak when parsing xml

I'm trying to parse an xmlfile almost like the seismicXML sample. What I do is the following:

I have created a object called XMLReader exactly like in the sample from apple. And then to init the object and start parsing:

NSURL *myUrl = [NSURL URLWithString:sendUrl];
XMLReader *streamingParser = [[XMLReader alloc] init];
[streamingParser parseXMLFileAtURL:myUrl parseError:&parseError];
[streamingParser release];
NSLog([NSString stringWithFormat:@"retainCount of myUrl: %i",[myUrl retainCount]]);


In the parseXMLFileAtURL:

NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:URL];
[parser setDelegate:self];
[parser parse];
[parser release];


In instruments I can see I have a memory leak with NSMachPort and CFRunLoopSource (whats this?) both seem to come from the parseXMLFileAtURL. What I can see is also that myUrl have a retainCount of how the same size as how many rows I have parsed from the xml when writing it to the log. 7 in my case, so I think this is maybe what's wrong but I'm not sure how to do this, I can't release myUrl as I'm not init it? And in the parseXMLFileAtURL all I do is passing it onto the initWithContentsOfURL-method, can't see whats wrong here, anyone?

Thanks really much for your help!

Message was edited by: martymart

Message was edited by: martymart

Mac OS X (10.5.3)

Posted on Aug 29, 2008 2:03 PM

Reply
8 replies

Aug 30, 2008 2:04 AM in response to etresoft

Yes I have a autorelease pool, it looks like this

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSURL *myUrl = [NSURL URLWithString:sendUrl];
XMLReader *streamingParser = [[XMLReader alloc] init];
[streamingParser parseXMLFileAtURL:myUrl parseError:&parseError];
[streamingParser release];
NSLog([NSString stringWithFormat:@"retainCount of myUrl: %i",[myUrl retainCount]])
[pool release];


Maybe the NSURL isn't the problem then, what can it be then?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Memory leak when parsing xml

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.