Hello, all
I'm parsing in large XML files (e.g. 50-200mb) and I find that the memory usage both during the parse and after releasing the NSXMLDocument or the NSXMLParser is still huge.
With alloc/init of a large XML file with NSXMLDocument I find that the memory consumed is about 7-10 times the size of the file.
With alloc/init of large XML with NSXMLParser the memory consumed is about 4X the size of the file.
After releasing either the NSXMLDocument or the NSXMLParser (and thus triggering dealloc) I find that about 80% of the memory used by that object is still consumed.
I am sure that my retain/release are balanced and I'm sure that dealloc is getting triggered on both types of parsers.
I am using Activity Monitor to view the memory consumption of the process. I've also used Instruments/Object-Alloc to see what AppKit is doing with the memory, the breakdown is the following:
GeneralBlock-<some number>: is taking up about half the memory or more consumed by the NSXML parser
CFString: is taking up about a quarter
CFDictionary: is taking up about a quarter if you use NSXMLParser, if you use NSXMLDocument as the parser the remaining quarter is in GeneralBlock
It seems to me like the memory in GeneralBlock-<some number> is a buffer that the NSXML parser uses to take bytes from the file and then create Foundation/AppKit objects from.
If this is true or not, why am I not recovering all of the memory once I'm done parsing the large XML? Note: I'm not making references or retaining any of the objects created in the object graph rooted at the NSXMLDocument or NSXMLParser instance.
Is Activity Viewer giving me a false picture of the memory consumption?
Thanks in advance for help!
Code on!
-Michael C Gilson
I'm parsing in large XML files (e.g. 50-200mb) and I find that the memory usage both during the parse and after releasing the NSXMLDocument or the NSXMLParser is still huge.
With alloc/init of a large XML file with NSXMLDocument I find that the memory consumed is about 7-10 times the size of the file.
With alloc/init of large XML with NSXMLParser the memory consumed is about 4X the size of the file.
After releasing either the NSXMLDocument or the NSXMLParser (and thus triggering dealloc) I find that about 80% of the memory used by that object is still consumed.
I am sure that my retain/release are balanced and I'm sure that dealloc is getting triggered on both types of parsers.
I am using Activity Monitor to view the memory consumption of the process. I've also used Instruments/Object-Alloc to see what AppKit is doing with the memory, the breakdown is the following:
GeneralBlock-<some number>: is taking up about half the memory or more consumed by the NSXML parser
CFString: is taking up about a quarter
CFDictionary: is taking up about a quarter if you use NSXMLParser, if you use NSXMLDocument as the parser the remaining quarter is in GeneralBlock
It seems to me like the memory in GeneralBlock-<some number> is a buffer that the NSXML parser uses to take bytes from the file and then create Foundation/AppKit objects from.
If this is true or not, why am I not recovering all of the memory once I'm done parsing the large XML? Note: I'm not making references or retaining any of the objects created in the object graph rooted at the NSXMLDocument or NSXMLParser instance.
Is Activity Viewer giving me a false picture of the memory consumption?
Thanks in advance for help!
Code on!
-Michael C Gilson