NSXMLDocument's initWithContentsOfURL is sometimes really slow on loading a URL's contents
As the title says, some URLs take less than a second to load in the browser, but in my cocoa app, running the following line repeatedly results in initWithContentsOfURL sometimes taking up to 30 seconds to load the URL. What may be the source of this problem?
I'm calling it like this:
NSXMLDocument* aDoc = [[NSXMLDocument alloc] initWithContentsOfURL:theURL options:NSXMLDocumentTidyXML error:&err];
Edits:
- It is an HTTP document
- I'm using NSXMLDocumentTidyXML arbitr开发者_开发知识库arily, are different options better?
- I'm loading the same URL every time, but some times it takes WAY longer than usual
- I am releasing this document correctly
- I am calling this from a seperate thread
- Looking at Activity Monitor, the times when the line takes 30 seconds to finish, Activity Monitor shows a spike in the beginning, and then no network activity for the rest of the time
精彩评论