Qt-interest Archive, January 2008
Memory cost in using DOM in Trolltech Qt
Message 1 in thread
Dear XML developers,
I did experiments on following code to see memory cost:
// before
QDomDocument domDocument;
QString errorStr; int errorLine, errorColumn;
if (!domDocument.setContent(content, true, &errorStr, &errorLine,
&errorColumn)) return 0;
// after
In debug mode, it costs 35 times larger than the xml file size.
In release mode, it costs 18 times larger than the xml file size.
For example (size in kb)
huge.xml: mem 372868(after) - 18936(before) = 353932(diff) (/10134
disk size = 35 times)
I also test DOM in Xerces. It costs in debug mode 9 times larger.
Does anyone have idea how to save memory in Qt DOM parser?
If Qt DOM parser is so expensive, we may have to drop it.
Thanks,
Lingfa
--
[ signature omitted ]
Message 2 in thread
On January 22, 2008 10:48:12 am Lingfa Yang wrote:
> Dear XML developers,
>
> I did experiments on following code to see memory cost:
> // before
> QDomDocument domDocument;
> QString errorStr; int errorLine, errorColumn;
> if (!domDocument.setContent(content, true, &errorStr, &errorLine,
> &errorColumn)) return 0;
> // after
>
> In debug mode, it costs 35 times larger than the xml file size.
> In release mode, it costs 18 times larger than the xml file size.
> For example (size in kb)
> huge.xml: mem 372868(after) - 18936(before) = 353932(diff) (/10134
> disk size = 35 times)
>
> I also test DOM in Xerces. It costs in debug mode 9 times larger.
>
> Does anyone have idea how to save memory in Qt DOM parser?
> If Qt DOM parser is so expensive, we may have to drop it.
>
> Thanks,
> Lingfa
If memory use is an issue such as when parsing large XML documents, why are
you doing so using a DOM parser instead of an event-based parser like the Qt
SAX2 classes?
--
[ signature omitted ]
Message 3 in thread
> If memory use is an issue such as when parsing large XML documents, why are
> you doing so using a DOM parser instead of an event-based parser like the Qt
> SAX2 classes?
>
Yes, use SAX instead of DOM is one solution. The pain is we have to stop
using XPATH.
The remain question is why Qt DOM (35 times) costs much more than Xerces
DOM (9 times)?
--
[ signature omitted ]