Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using 'Analyze Memory' tool in Qt Creator

I am using Qt Creator to develop a C++ application, and I am trying to track down some memory leaks.

I have followed these instructions*, and have Valgrind isntalled on my Ubuntu machine.

I begin my application from the Analyze Memory section, and after clicking the stop button I am told that Tool Analyze Memory finished, 928 issues found. However, no results appear in the analysis section, which remains blank.

Am I doing something wrong? Where can I find the results of the memory analysis?


*Confusingly, the instructions ask for a 'release' build configuration, but selecting this causes a warning in Qt saying that the memory analysis tool requires a debug configuration. I have tried both ways round.

like image 434
Bill Cheatham Avatar asked Dec 12 '11 11:12

Bill Cheatham


People also ask

How do you use Valgrind memory analyzer in Qt?

You can run the tools on a remote Linux machine or device from any development host. To run the Valgrind tools to analyze an application for which you have a project, open the project in Qt Creator and select the kit to run the project. The kit specifies whether the Valgrind tools are run locally or remotely.

How to run Valgrind in Qt Creator?

To run the Valgrind tools to analyze external applications for which you do not have a Qt Creator project: Select Analyze > Valgrind Memory Analyzer (External Application) or Valgrind Function Profiler (External Application). Specify the application to run and analyze, and the kit to use.


2 Answers

I've checked it in my Qt Creator and it works. I'm using version 2.3.1 with Qt 4.7.4 and Valgrind 3.7.0. I've tested it on dropsite example with Debug build configuration. I've also tested it with my CMake based project (compiled with -g and -O0 flags) and it also worked. Make sure, that next to start button Valgrind Memory Analyzer is chosen. On the same bar you'll find arrow icons. Next to them is icon of funnel (I think). Click it and make sure that types of errors you're interested in are checked.

If it won't work, and you don't want to use Valgrind tools from console, there are other Valgrind GUIs like Valkyrie.

EDIT: I've updated Qt Creator to version 2.4.0rc1 and checked it with my CMake project. It also showed no results, while reporting few hundred issues. Solution to this was checking External errors after clicking funnel icon.

EDIT2: In final 2.4.0 issue was fixed.

like image 187
Maciej Avatar answered Sep 22 '22 14:09

Maciej


You did nothing wrong. In the Valgrind menu, press the Filter icon and select External Errors. You will see all issues appearing. Those are most likely not from your application, but Qt- or else-related, so you can often ignore them.

X issues found refers to the total number of issues; when External Errors is unselected, only those related to your app show up. If none appears, Valgrind has not detected any memory leak in your app.

like image 42
Jorge Leitao Avatar answered Sep 19 '22 14:09

Jorge Leitao