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?