Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Running Valgrind on a Library to detect Memory Leaks if any



  • Hello

    I have a library on which I want to check memory leaks.
    I make a testing program and run the functions from the library, it shows me some issue on the statement where i define the object.
    Now, I want to test on the library to find the exact statements where there might be some leaks.
    I dont know how to do that.

    Can someone help here.



  • There are static memory analysis tools that would find some quick wins (probably).

    What environment are you running?

    I use Valgrind in Linux and Clang Static Analyzer in windows.
    I use the online binaries of latest released Qt
    I run with GCC compiler for linux, mingw and VS for windows...

    It's a pretty easy process either way, load of info around. Basically just run it up in the debugger but under static analysis and find the obvious wins!



  • For the testing, I am using Ubuntu with Valgrind on Qt5.10.1

    What are the best static tools for Linux?



  • I don't know all the tools of course, I've never needed any more than Valgrind and that suite.

    If there's other automated tools or other tools that people find equally invaluable, I wouldn't mind knowing either =) - good tools are good to know about.

    I use this too - https://gres.biz/qtc-cppcheck/ - it catches more easy mistakes / makes like generally pleasant.
    https://github.com/OneMoreGres/qtc-cppcheck/releases

    I get a couple of "The function '' is never used" where they are only called via a signal connection... but all the other warnings and suggestions are really nice.
    That's an Qt Creator plugin that I always put on.



  • @6thC
    Thanks for this information. I will download and try to use this static tool.
    But other than static tool, does any one know of a dynamic tool for finding memory leaks from a library?


Log in to reply