[Interest] valgrind

Jonathan Greig redteam316 at gmail.com
Mon Jul 8 12:55:02 CEST 2013


Paul,
Can you please explain your reasoning or how it might go wrong as "barely
more" sounds exactly what I want and what Alex is asking for. My reasoning
is that it catches all of MY memory leaks, but supresses the gazillions of
memory leaks that aren't directly created by me (Such as memory leaks
within Qt or one of it's dependencies).

I've attached a minimal compile-able example that has a obvious memory leak
in it. I'll also paste it directly into this email because it's so small:

main.cpp

> #include <QApplication>
> #include <QWidget>
> int main(int argc, char *argv[])
> {
>     QApplication app(argc, argv);
>     QWidget* leak = new QWidget();      //No parent is specified, so we
> must delete this manually
>     leak->setMinimumSize(300, 300);
>     QWidget* child = new QWidget(leak); //No need to delete manually as Qt
> handles memory cleanup
>     leak->show();
>     int result = app.exec();
>     //delete leak; //Uncomment this line and Valgrind is happy.
>     return result;
> }


When running valgrind with leak detection off and no suppressions, it's
clearly useless because it doesn't report the memory leak:

> valgrind --leak-check=no --show-reachable=yes --error-limit=no
>  --gen-suppressions=all --log-file=_memleak.txt -v ./leaktest


When running valgrind with leak detection on and using my supression files,
it reports the one memory leak I was really concerned with:

> valgrind --leak-check=full --show-reachable=yes --error-limit=no
> --suppressions=../valgrind-supp/./valgrind-qt.supp
> --suppressions=../valgrind-supp/./valgrind-misc.supp --gen-suppressions=all
> --log-file=_memleak.txt -v ./leaktest


==25878== LEAK SUMMARY:
> ==25878== definitely lost: 40 bytes in 1 blocks
> ==25878== indirectly lost: 40 bytes in 1 blocks
> ==25878== possibly lost: 0 bytes in 0 blocks
> ==25878== still reachable: 3,424 bytes in 5 blocks


It also shows me that there are about 3.5 kilobytes that are still
reachable due to unicode stuff that I really has nothing to do with the
minimal example at all.




On Mon, Jul 8, 2013 at 8:11 AM, <paulf at free.fr> wrote:

> ----- Original Message -----
> >
> >
> > Alex,
> > Supposedly QtCreator uses one internally or something but I haven't
> > been able to locate it. I asked about this awhile back and thats the
> > general consensus. I'm pretty sure that what you are looking for is
> > what I have here:
> > http://sourceforge.net/p/embroidermodder/code/178/tree/valgrind-supp/
> > The valgrind-qt.supp file was made for Qt4 so if you are using Qt5,
>
> Hi
>
> I would advise against using such a suppression file. Basically it
> suppresses all leaks that have Qt somewhere in the call stack. If you're
> writing a Qt app, this will give you barely more leak detection than if you
> run Valgrind with leak detection turned off.
>
> A+
> Paul
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130708/c49154f7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: valgrind-qt-minimal.zip
Type: application/zip
Size: 62313 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130708/c49154f7/attachment.zip>


More information about the Interest mailing list