Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-29-2008, 05:05 PM   #1 (permalink)
Registered Member
 
Join Date: May 2008
Posts: 133
Default 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!
martinn is offline   Reply With Quote
Old 08-30-2008, 03:58 AM   #2 (permalink)
New Member
 
Join Date: Apr 2008
Location: Germany
Posts: 154
Default

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?
ChriB is offline   Reply With Quote
Old 12-20-2008, 04:56 AM   #3 (permalink)
Mobile Application Dev.
 
Join Date: Oct 2008
Location: Bangalore, india
Posts: 362
Default

Quote:
Originally Posted by martinn View Post
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.
mpramodjain is offline   Reply With Quote
Old 12-20-2008, 10:17 AM   #4 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 495
Default

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!
exorcyze is offline   Reply With Quote
Old 01-05-2009, 07:57 PM   #5 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 22
Default

This seems to answer this problem...
Memory leak problem - Mac Forums
Hope that helps!
ichi is offline   Reply With Quote
Old 01-16-2009, 07:00 PM   #6 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 1
Default 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.
matthewmccull is offline   Reply With Quote
Old 01-16-2009, 07:12 PM   #7 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 22
Default

Here is another possible solution, which sorted it for me in the end...
http://www.iphonedevsdk.com/forum/ip...html#post39064

Solution was found here...
Cocoabuilder - (John Mikros) Re: NSURLConnection leaking on multi-threaded apps?
ichi is offline   Reply With Quote
Old 03-25-2009, 11:22 AM   #8 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 6
Default 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.
JBMJBM is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 157,869
Threads: 88,917
Posts: 379,300
Top Poster: BrianSlick (7,072)
Welcome to our newest member, homasen
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:19 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0