You can use the Memcheck tool included in the Valgrind tool suite to detect problems that are related to memory management in applications.
Note: Memcheck is supported locally on Linux and Mac OS. You can run it on a remote host from Windows.
After you download and install Valgrind tools, you can use Memcheck from Qt Creator.
To analyze applications:
While the application is running, Memcheck checks all reads and writes of memory and intercepts calls that allocate or free memory or create or delete memory blocks. When you stop Memcheck, it displays the results in the Analysis view. Click a line to view where a memory leak occurred and a stack trace that shows what caused it.
Move the mouse on a row to view more information about the function.
For more information about using Memcheck, see Interpreting Memcheck's Output in the Valgrind documentation.
You can specify analyzer settings either globally for all projects or separately for each project in the run settings of the project.
Stack traces can get quite large and confusing, and therefore, reading them from the bottom up can help. If the stack trace is not big enough or it is too big, select Tools > Options > Analyzer. Define the length of the stack trace in the Backtrace frame count field.
Memcheck also reports uses of uninitialised values, most commonly with the message Conditional jump or move depends on uninitialised value(s). To determine the root cause of these errors, the Track origins of uninitialized memory check box is selected by default. You can deselect it to make Memcheck run faster.
Memcheck detects numerous problems in the system libraries, such as the C library, which come pre-installed with your OS. As you cannot easily fix them, you want to suppress them. Valgrind reads a list of errors to suppress at startup. A default suppression file is created by the ./configure script when the system is built.
You can write your own suppression files if parts of your project contain errors you cannot fix and you do not want to be reminded of them. Click Add in the Memory Analysis dialog to add the suppression files. For more information about writing suppression files, see Suppressing Errors in the Valgrind documentation.