 |
 |
|
 |
08-29-2008, 05:05 PM
|
#1 (permalink)
|
|
Registered Member
Join Date: May 2008
Posts: 120
|
Memory leak
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!
|
|
|
08-30-2008, 03:58 AM
|
#2 (permalink)
|
|
New Member
Join Date: Apr 2008
Location: Germany
Posts: 154
|
The docs say:
Quote:
URLWithString:
Creates and returns an NSURL object initialized with a provided string.
+ (id)URLWithString: (NSString *)URLString
|
So isn't that auto-allocating and initializing the object? That way a release is needed, or am I wrong?
|
|
|
12-20-2008, 04:56 AM
|
#3 (permalink)
|
|
Mobile Application Dev.
Join Date: Oct 2008
Location: Bangalore, india
Posts: 243
|
Quote:
Originally Posted by martinn
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!
|
Hi, I am also having the same problem.
If u found the solution, please help me...
Thank u.
|
|
|
12-20-2008, 10:17 AM
|
#4 (permalink)
|
|
Registered Member
Join Date: Dec 2008
Posts: 495
|
I wish I had the answer to your question, but I'm a bit curious what's amiss too as it looks ok to me - in general my understanding is you only release objects you "own", which happens when you alloc, retain or copy. You seem to have those bases covered, and convenience constructors should autorelease afaik.
However, I did notice that you were creating an NSString inside your log statement. NSLog does a stringWithFormat on it's own so you could shorten that log statement to be:
Code:
NSLog( @"retainCount of myUrl: %i",[myUrl retainCount] );
Good luck with the leak!
|
|
|
01-16-2009, 07:00 PM
|
#6 (permalink)
|
|
New Member
Join Date: Jan 2009
Posts: 1
|
iPhone SDK Has some APIs that do Leak
You definitely want to try the Instrumentation option for "Leaks" and let it tell you where the leak is coming from. I used this tool (part of XCode, in the Run menu) to find the leak inside the sendSynchronousRequest method call on NSURLConnection. Details here on my blog post.
|
|
|
01-16-2009, 07:12 PM
|
#7 (permalink)
|
|
New Member
Join Date: Aug 2008
Posts: 22
|
|
|
|
03-25-2009, 11:22 AM
|
#8 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Posts: 4
|
Problem Loading Some RSS Feeds but Others Fine?
Here is the problem I am having. For the following RSS feed example, I am having trouble getting it to load the feed. Comes up with an error that it cannot connect. However on my Mac RSS Reader it works fine, so I know the link is good.
Any ideas on why it cannot load this particular feed but it can load others fine?
OSU Headline News
Thanks.
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 515 |
| 57 members and 458 guests |
| aoredsson, beausejour, bensj, BustinStones, chinhminhdo, CHV, codeMonkey, conanjb, CoolApps, Corey, CunningCat, dany88, dda, DorkyMohr, dre, ggalante, healthyutech, iPhoneDevelopment, Jeremy1026, john3478, jorgmart, JoshuaCaputo, katyaskr, KennyChong, kkrimmer, LoDani, LunarMoon, macoholic, Maximilian, mlo, MMan, Mr Jack, mriphoneman, MrMattMac, Nightmare_82, not_too_shabby, NSeven, opetopic, pablo.roqueta, pablox, pierotofy, rarindeed, Rudy, ryguy2503, salva, seriessix, sgraves, stubbsjoe, supudo, Tambourin, themathminister, vcanic, virvalid, Vivek Nirkhe, warmi, wuf810, ZunePod |
| Most users ever online was 779, 05-11-2009 at 10:55 AM. |
» Stats |
Members: 21,495
Threads: 35,777
Posts: 156,729
Top Poster: smasher (2,448)
|
| Welcome to our newest member, AnuSambath |
|