- Qt Creator Documentation
- Detect memory leaks with Memcheck
- Qt Creator 21.0.0-beta1

Detect memory leaks with Heob ◦ Explore compiler code

# Detect memory leaks with Memcheck

With the Memcheck tool in Valgrind's Tool Suite, you can detect problems that are related to memory management in applications. Use the tool together with the GDB debugger. When a problem is detected, the application is interrupted and you can debug it.

Note: You can install and run Memcheck locally on Linux. You can run it on a remote host or device from any computer. On Windows, you can use the Heob heap observer to receive similar results.

After you download and install Valgrind tools, you can use Memcheck from Qt Creator.

To detect memory leaks in applications:

1. Go to the Projects mode, and select a debug build configuration.
2. In the mode selector, select Debug > Memcheck.

3. Select to start the application.
4. Use the application to analyze it.
5. Select to view the results of the analysis in Memory Issues.

## View memory issues

While the application is running, Memcheck does the following:

- Checks all reads and writes of memory.
- Intercepts calls that allocate or free memory or create or delete memory blocks.

You can see the results when you stop Memcheck. Qt Creator divides the issues into categories and displays them if they belong to the running application. By default, it filters out other issues (such as issues from external libraries).

Select a line to see the place where a memory leak occurred and a stack trace that shows what caused it.

As an alternative to collecting data, select to load an external log file in XML format into the Memcheck view.

Move the mouse on a row to view more information about the function.

To move between rows, select (Previous) or (Next).

For more information about using Memcheck, see Interpreting Memcheck's Output in the Valgrind documentation.

## Filter memory issues

To filter the results, select , and then select the types of issues to display in the view:

- Definite and possible memory leaks
- Use of uninitialized memory
- Invalid calls to `free()`
- Size and alignment errors
- File descriptor issues

Select Other to show issues that do not belong to any category.

Select External errors to also show issues from external libraries.

See also How to: Analyze, Profile function execution, Run Valgrind tools on external applications, Specify Valgrind settings for a project, Analyzers, Valgrind Callgrind, Valgrind Memcheck, and Analyzing code.

Detect memory leaks with Heob ◦ Explore compiler code