Re: Expat loading the entire file in memory?
Guillaume Drevon <[email protected]> Mon, 4 Apr 2011 10:27:15 +0100
| Newsgroups | gmane.text.xml.expat.general |
|---|---|
| Message-ID | <750C20E09BB8BF458D0AC0A0CE22B98D27D70A01CD@IE-ML-01v.patchlink.com> |
I have been able to solve my issue. In fact there is a macro that you need to define before building expat lib: XML_MIN_SIZE With this, expat will keep the memory usage very low. In my case, it was below 3MB, which is much much less than 500MB! Expat documentation warns that this option will make expat running slower so this is why it is not the default behavior. This makes sense as it will work well except for extreme files like mine. Note that expat was not loading the entire file in memory, as else it would have needed 1GB due to the unicode conversion. On Wed, Mar 30, 2011 at 12:08 PM, Guillaume Drevon <[email protected]> wrote: > I am trying to use Expat for parsing a 500MB file. I read the file by chunks (of 1000 byte) and send them to the parser. However, the memory used by my application goes up to 550 MB. > The memory usage is entirely done by expat as the XmlParserFree does remove almost all memory consumption. I see that the memory is mostly used by the m_buffer member of the parser. > > Am I doing something wrong? The purpose of this SAX-like parser is not memory usage?