NSXMLParser memory consumption
NSXMLParser memory consumption
- Subject: NSXMLParser memory consumption
- From: George King <email@hidden>
- Date: Sat, 4 Apr 2009 09:02:29 -0700
Hi List,
I hit a stumbling block when passing large files (multi-GB) to
NSXMLParser. It appears that NSXMLParser's initWithContentsOfURL:
method loads the contents of the entire file into memory, which is
causing virtual memory thrashing for at file sizes approaching my
physical RAM (2 GB in this case, so I start seeing performance issues
at around 1.3 GB). After reading the CFXMLParser documentation, I
suspect that core foundation does the same thing.
Can somebody suggest an alternative API for parsing xml that does not
have memory requirements linear with file size for the initialization?
Given the event-driven design I originally imagined that the parser
would read through a file incrementally, without loading it all into
memory.
Also, would it be appropriate to file a bug / enhancement request for
this issue?
Note that once the NSXMLParser delegate starts receiving messages, I
am able to keep memory usage under control by giving the delegate its
own autorelease pool and draining/replacing it once every x calls to
parser:didStartElement....
I started looking into libxml2 but then thought I'd ask here first.
Any suggestions would be much appreciated. Thanks!
George
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden