The Good, the Bad and the Ugly



The Good: QXmlSimpleReader or QXmlQuery can be used to parse xml results in Qt. With QXmlSimpleReader (which is very low-level), one should write their own routine for every different xml structures – which is boring and not effective interms of code maintainance. Whereas QXmlQuery is a convenient way to parse xml structures from different sources using XQuery statements – it directly returns the result and queries are text statements, hence need not be shipped within code.

The Bad: QXmlSimpleReader is memory efficient ; QXmlQuery is not really memory efficient (Qt is working on these memory issues ).

And The Ugly: In Symbian if QXmlQuery is used in iteration (which is the majority case in most xml parsing scenarios) your app errors “Low memory, close some applications to continue”. Before getting into abusing Symbian one should understand how it runs an app.  The app itself specifies how much stack and heap size it needs and Symbian tells “hey please execute respecting these limits, else I will be forced to terminate you!” , which sounds reasonable.  So due to these memory conditions a piece of code running QXmlQuery under iteration will lead to low memory condition. This holds true even if you create QXmlQuery as a local variable or create an instance on demand – believe me.

So what is the way out? Well, nothing so far which blocks all memory issues until they are fixed in Qt. But we can make the app run better by making the QXmlQuery a member variable and allocate memory on heap, so that we reduce the chances of creating multiple QXmlQuery instances and hence control the amount of memory leaks by many folds.

The Good: QXmlSimpleReader or QXmlQuery can be used to parse xml results in Qt. With QXmlSimpleReader (which is very low-level), one should write their own routine for every different xml structures - which is boring and not effective interms of code maintainance. Whereas QXmlQuery is a convenient way to parse xml structures from different sources using XQuery statements - it directly returns the result and queries are text statements, hence need not be shipped within code.

The Bad: QXmlSimpleReader is memory efficient ; QXmlQuery is not really memory efficient (Qt is working on these memory issues 🙂 ).

And The Ugly: In Symbian if QXmlQuery is used in iteration (which is the majority case in most xml parsing scenarios) your app errors "Low memory, close some applications to continue". Before getting into abusing Symbian one should understand how it runs an app.  The app itself specifies how much stack and heap it needs,  and Symbian tells "hey please execute respecting these limits, else I will be forced to terminate you!" , which sounds reasonable.  So due to these memory conditions a piece of code running QXmlQuery under iteration will lead to low memory condition. This holds even you create QXmlQuery as a local variable or create an instance on demand - believe me. 

So what is the way out? Well, nothing so far which blocks all memory issues until they are fixed in Qt. But we can make the app run better by making the QXmlQuery a member variable and allocate memory on heap, so that we reduce the chances of creating multiple QXmlQuery instances and hence control the amount of memory leaks by many folds.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s