I'm developing a console Qt application that modifies lots of xml files. I noticed that my app starts to consume more and more memory over the time. For example it has been working for an hour and the memory consumption raised from 300 Mb to 700 Mb.
I used valgrind in Qt Creator Analyze mode to get what's going on. The valgrind log is full of messages like this:
155,568 (72 direct, 155,496 indirect) bytes in 9 blocks are definitely lost in loss record 1,104 of 1,107
in XmlValidator::validateXsd(QString const&, QString const&, QXmlSchema*) in xml_validator.cpp:302
1: operator new(unsigned long) in /builddir/build/BUILD/valgrind-3.6.0/coregrind/m_replacemalloc/vg_replace_malloc.c:261
2: /usr/lib64/libQtXmlPatterns.so.4.6.2
3: /usr/lib64/libQtXmlPatterns.so.4.6.2
4: /usr/lib64/libQtXmlPatterns.so.4.6.2
5: /usr/lib64/libQtXmlPatterns.so.4.6.2
6: /usr/lib64/libQtXmlPatterns.so.4.6.2
7: /usr/lib64/libQtXmlPatterns.so.4.6.2
8: /usr/lib64/libQtXmlPatterns.so.4.6.2
9: QXmlSchema::load(QByteArray const&, QUrl const&) in /usr/lib64/libQtXmlPatterns.so.4.6.2
...
As I can see, all of these messages point that something is wrong within QXmlShema::load
function. I use QXmlShema
object in one of my function and it is a local object that should be destroyed after the function ends.
Is it really something wrong with the QtXmlPatterns
classes or I don't understand the valgring log properly?
--update--
Here is a part of my code:
bool Validator::validateXsd(const QString &xsd, const QString &uri)
{
QXmlSchema schema;
return this->validateXsd(xsd, uri, &schema);
}
bool Validator::validateXsd(const QString &xsd, const QString &uri, QXmlSchema *schema)
{
if (schema == NULL)
{
return false;
}
bool valid = schema->load(xsd.toUtf8(), uri);
return valid;
}