cocoa - NSXMLParser Memory Allocation Efficiency for the iPhone -


I am currently playing with the iPhone app's code to parse XML. Sticking to cocoa, I decided to go with the NSXLL parser class. The app will be responsible for parsing 10,000+ "computers", for all my information which has 6 other wires for the test, I have verified that the XML is around 900k-1MB in size.

My data model is to put each computer in NSDictionary washed by a unique identifier. Each computer with information is also represented by an NSDictionary, so at the end of the day, I end up with an NSDictionary that contains 10k other NSDictionaries.

The problem I am running is not about leaking storage or memory of efficient data structure. When my parser, allocate the total amount of goods is only one moving MB problem is that when NSXMLParser running, my object allocation is growing as much as 13 MB. I can understand 2 (one object for which I am making and one for raw NSDT) plus a little room to do the work, but 13 seems to be a bit higher. I can not imaging that NSXMLParser disabled idea

Code ...

parsing code to start ...

  NSXMLParser * Parser = [[NSXMLParser alloc] initWithData: data]; [Parsets set DeliGet: Dixspacer]; [Parser pars]; Output = [[Dyspersper's returnaworthy] is maintained); [Parser release]; [Dixopers release];  

and parser representative code ...

  - (void) parser: (NSXMLParser *) parser didStartElement: (NSString *) elementName namespaceURI :( NSString *) namespaceURI qualifiedName: (NSString *) qualifiedName attributes responsible: (NSDictionary *) attributeDict {if (mutableString) {[mutableString release]; MutableString = Zero; } MutableString = [[NSMutableString alloc] init]; } - (void) parser: (NSXMLParser *) parser foundCharacters: (NSString *) string {if (self.mutableString) {[self.mutableString appendString: string]; }} - (void) parser: (NSXMLParser *) parser didEndElement: (NSString *) elementName namespaceURI: (NSString *) namespaceURI qualifiedName: (NSString *) QName {if ([ElementName IsEqualToString: @ "size"]) {// The initial key, tells me how many computers are returnDictionary = [[NSMutableDictionary alloc] initWithCapacity: [mutableString intValue]]; } If ([elementName isEqualToString: hashBI]) // // unique identifier if (mutableDictionary) {[mutableDictionary release]; MutableDictionary = Zero; } MutableDictionary = [[NSMutableDictionary alloc] initWithCapacity: 6]; [ReturnDictionary set object: [Ansdisd Skwayrsः Vijisn: Key to Mutiv Description]: [Ansmutbl string with string: Mutiv string]]; } If there are any [mutableDictionary setObject: mutableString forKey: elementName] ([areas areObject: elementName]) {// that I see from the same computer; }}  

Everything was started and released correctly. Again, I'm not getting errors or leaks just unskilled.

Thanks for any thoughts!

Nothing special can say about your code, but take a look at Apple's sample - It compares the NSXMPP and BBCML performance - the results are definitely in favor of the latter. Switched a great performance from NSXMLParser into one of my projects that switched to libxml, so I suggest using it.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -