Memory leak checking on Windows with QT and MinGW32

眉间皱痕 提交于 2019-12-18 13:17:01

问题


Lately I have been developing in C++ with QT Creator. All is well and I'm nearly at the point of packaging and distributing my application. But obviously before any release you better make sure you have everything right. So I'm at the testing stage, and something tells me that I have some slight memory issues. Nothing serious, but I like to obsess over these ;-).

So I decided to try some memory leak detection libraries. For starters I looked at this question. I disregarded Purify and Insure++ because of the costs. Someone else suggested to use the MSVC compiler so I could use the CRT memory validation routines. Which I considered but decided against for now because of the implications it would have on using the debugger from within QT Creator.

Then I stumbled across DUMA which I got to compile using the MinGW32 compiler that comes with QT. However, I found that it doesn't really play well with QT because of the incredible amount of segmentation faults. I know they are how DUMA works, but I'm pretty sure I did not screw things up as much as DUMA tried to make me believe.

Another something I tried was the google-performance-tools which I sadly cannot get to compile with the MinGW32 version supplied with QT, even if I add in the required dependencies.

All of this brings me to my question: Is there any working solution out there for QT Creator developers that want to check their programs for memory leaks?

Thanks,


回答1:


Personally, I find the valgrind / memcheck / callgrind / kcachegrind combo to be too powerful to pass up for memory leaks and performance analysis. Being free (gratis) is especially nice since I cannot personally afford the cost of some of these other professional tools.

I've been working on a cross platform Qt application for a couple years now. As I develop, I bounce back and forth between windows and linux when I want to test features and functionality. However, I always do my performance analysis in linux. The memory leaks and performance concerns that I find are always ones that are injected by my team of developers on top of Qt. So when these problems are fixed, regardless of being identified in Linux, the benefits will carry over into windows.

I suggest you investigate setting up a pure linux build environment that you can test in. Perhaps the easiest solution for you would be to create a virtual machine to do your performance analysis on. My preferred combination is VirtualBox and Ubuntu.




回答2:


May be you can use these libs for windows

Hooks for Malloc [gnu.org] Backtrace [gnu.org] valgrind [valgrind.org]



来源:https://stackoverflow.com/questions/4527325/memory-leak-checking-on-windows-with-qt-and-mingw32

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!