PDA

View Full Version : qxmlquery memory leak



jaxrpc
25th June 2010, 11:03
Hi all,

i am using xquery to retrieve xml data in Qt with QXmlQuery but i realised that there are some memory leak with QXmlQuery. It looks like it failed to release some the memory it has allocated. I need to run xquery against a xml pretty frequent so the leak can get quite bad.

Anyone else facing the leaking problem? What are the available open source libraries for xquery?

thanks

borisbn
25th June 2010, 12:02
Can you show a code, please ( just a fragment, that that makes memory leak ). I'm using QXmlQuery and I don't want to have this problem in my program.
Thanks

jaxrpc
25th June 2010, 18:49
do a simple setquery call multiple times in a loop and you can see it

borisbn
26th June 2010, 10:03
I wrote a simple example, run it and monitored memory by windows task manager. Then I remarked this code and view memory usage again, and I don't see any changes. I use Windows 7 + Qt 4.6.2 + MXVC2008. Here is my code.


QByteArray byteArray = "<?xml version='1.0' encoding='Windows-1251'?>"
"<widget>"
"<property name='text'>Текст</property>"
"</widget>";
for ( int i = 0; i < 1000000; i++ )
{
QBuffer buffer( &byteArray );
buffer.open( QIODevice::ReadOnly );
QXmlQuery xmlQuery;
xmlQuery.bindVariable( "myDocument", &buffer );
xmlQuery.setQuery("string(doc($myDocument)/widget/property[@name='text'])");
bool v = xmlQuery.isValid();
QString sss;
bool eee = xmlQuery.evaluateTo( &sss );
buffer.close();
}

jaxrpc
28th June 2010, 20:34
hi i am on fedora,

memory increases fast , 1 thing to note is that my xml is huge...300 elements.
I detected the leak using valgrind and monitor it using top command

i will try to post my code snippet.