Suppression files for Qt memory leaks with Valgrind(使用 Valgrind 抑制 Qt 内存泄漏的文件)
问题描述
我通常用 C++ 编写我的类,并在 Linux 平台上使用 valgrind 检查它们是否泄漏内存.直到所有堆内存都被释放,我才满意.
I usually write my classes in C++ and check if they leak memory using valgrind on Linux platform. I'm not satisfied until all the heap memory is freed.
开始用 Qt 编写,我发现 valgrind 检测到多少泄漏,也是在一个简单的项目中.它们太多了,很难检测到我的相同泄漏.
Starting to write in Qt, I found how many leaks valgrind detects, also on a simple project. They are so many that it's difficult to detect my same leaks.
我在某处读到可以使用 valgrind 的抑制文件,这有助于过滤掉不需要的泄漏,但我找不到它.
I read somewhere that is possibile to use a suppression files for valgrind which helps filtering out the unwanted leaks, but I can't find it.
我使用的是 Ubuntu 11.04 x64、g++ 4.5、Qt 4.7.有人知道如何处理这个问题吗?
I'm using Ubuntu 11.04 x64, g++ 4.5, Qt 4.7. Does somebody know how to cope with this problem?
推荐答案
您是否查看了这个Valgrind Suppression File Howto"维基?
只是为了记录,Qt中有一些底层库(尤其是绘制过程中的库)总是泄漏少量内存.这些是您需要压制的.
Just for the record there are some underlying libraries in Qt (especially the ones in the painting process) which always leak small amount of memory. These are the one you need to suppress.
如您所说,您应该首先创建一个最小项目,运行它以创建一个 valgrind 抑制文件,然后将该抑制文件应用于您的项目.
As you said, you should first create a minimal project, run it to create a valgrind suppression file and then apply that suppression file to your project.
这篇关于使用 Valgrind 抑制 Qt 内存泄漏的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Valgrind 抑制 Qt 内存泄漏的文件


基础教程推荐
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 从 std::cin 读取密码 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01