0

I am writing a program in QT Creator and I just use these two lines in main.cpp function:

QString a = "10.98";
double b = a.toDouble();

Everything seems fine, but when I check it with valgrind it reports a memory leak:

valgrind --leak-check=full ./Example 

(...)

==15937== 
==15937== 242 (96 direct, 146 indirect) bytes in 1 blocks are definitely lost in loss record 50 of 60
==15937==    at 0x4C2C154: operator new(unsigned long) (vg_replace_malloc.c:298)
==15937==    by 0x533710E: ??? (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.1)
==15937==    by 0x53373DA: QLibrary::setFileNameAndVersion(QString const&, QString const&) (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.1)
==15937==    by 0x533744B: QLibrary::QLibrary(QString const&, QString const&, QObject*) (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.1)
==15937==    by 0x52A3894: ??? (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.1)
==15937==    by 0x5269F10: QLocalePrivate::updateSystemPrivate() (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.1)
==15937==    by 0x526A1EA: ??? (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.1)
==15937==    by 0x526A21C: ??? (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.1)
==15937==    by 0x526A389: QLocale::QLocale() (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.1)
==15937==    by 0x52923F3: QString::toDouble(bool*) const (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.1)
==15937==    by 0x40110D: main (in /host/Users/Tereza/Documents/CVUT-FSv/8.semestr/BP/example/Example)
==15937== 
==15937== LEAK SUMMARY:
==15937==    definitely lost: 192 bytes in 2 blocks
==15937==    indirectly lost: 284 bytes in 6 blocks
==15937==      possibly lost: 0 bytes in 0 blocks
==15937==    still reachable: 19,931 bytes in 58 blocks
==15937==         suppressed: 0 bytes in 0 blocks
==15937== Reachable blocks (those to which a pointer was found) are not shown.
==15937== To see them, rerun with: --leak-check=full --show-reachable=yes
==15937== 
==15937== For counts of detected and suppressed errors, rerun with: -v
==15937== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

The error could not be anywhere else because there is nothing more than these two lines.

Can anybody explain me what is wrong? Thanks.

EDIT: After few experiments I find out that this can be caused not by this operation specificly but maybe with some system setting or something like that. I had got similar errors using different functions and always valgrind report as a reason the same first four lines (as above) related to QLibrary::setFileNameAndVersion() function. Anyway, somebody knows the reason for this?

TinF
  • 89
  • 7
  • leak in qt library, or a false reporting – BЈовић May 27 '13 at 20:20
  • I see, but how to fix it? – TinF May 27 '13 at 20:37
  • I think you want to use a suppression file in this case, see [this link](http://wiki.wxwidgets.org/Valgrind_Suppression_File_Howto). Also there is a valgrind analyzer built directly into Qt Creator (the Analyze menu). I haven't yet tried this one myself, but some of my friends told me that they did not see any leaks when using this version of valgrind (it probably already includes all the necessary suppressions). – jcxz May 27 '13 at 20:40
  • I have used valgrind in qt and there are no leaks, thanks for your quick reaction. – TinF May 27 '13 at 20:44
  • It is actually Qt leak, and you shouldn't worry, because it doesn't metter. Qt loads an ICU library and doesn't unload it somewhere [until the program is terminated](http://qt-project.org/doc/qt-4.8/qlibrary.html#dtor.QLibrary). – Lol4t0 May 27 '13 at 20:56

0 Answers0