使用 valgrind 检查 fftw3

2024-01-07

在我的程序的一个步骤中,我需要对图像进行卷积。为此,我正在使用提供的功能fftw3。当我跑步时valgrind在我的程序中,我得到了这个堆栈跟踪。我的函数叫做convolve它运行fftw3's fftw_plan_dft_r2c_2d两次(一次在图像上,一次在卷积核上。为了使其更具可读性,我删除了所有地址和进程ID。

HEAP SUMMARY:
    in use at exit: 62,280 bytes in 683 blocks
  total heap usage: 178,271 allocs, 177,588 frees, 36,617,058 bytes allocated

3,304 (24 direct, 3,280 indirect) bytes in 1 blocks are definitely lost in loss record 129 of 131
   at : malloc (vg_replace_malloc.c:291)
   by : fftw_malloc_plain (in ./prog)
   by : fftw_mkapiplan (in ./prog)
   by : fftw_plan_many_dft_r2c (in ./prog)
   by : fftw_plan_dft_r2c (in ./prog)
   by : fftw_plan_dft_r2c_2d (in ./prog)
   by : convolve (freqdomain.c:199)
   by : convolve (conv.c:290)
   by : main (main.c:332)

3,304 (24 direct, 3,280 indirect) bytes in 1 blocks are definitely lost in loss record 130 of 131
   at : malloc (vg_replace_malloc.c:291)
   by : fftw_malloc_plain (in ./prog)
   by : fftw_mkapiplan (in ./prog)
   by : fftw_plan_many_dft_r2c (in ./prog)
   by : fftw_plan_dft_r2c (in ./prog)
   by : fftw_plan_dft_r2c_2d (in ./prog)
   by : convolve (freqdomain.c:203)
   by : convolve (conv.c:290)
   by : main (main.c:332)

LEAK SUMMARY:
   definitely lost: 48 bytes in 2 blocks
   indirectly lost: 6,560 bytes in 60 blocks
     possibly lost: 0 bytes in 0 blocks
   still reachable: 55,672 bytes in 621 blocks
        suppressed: 0 bytes in 0 blocks
Reachable blocks (those to which a pointer was found) are not shown.
To see them, rerun with: --leak-check=full --show-leak-kinds=all

For counts of detected and suppressed errors, rerun with: -v
ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 4 from 4)

根据手册的建议,完成后我已经使用了fftw_free and fftw_destroy_plan。我想看看我能对此做些什么还是这是一个内部问题fftw3?既然没有释放malloc位于 FFTW 源代码深处。

编辑:包含 fftw_cleanup() 之后

下面你可以看到diff我添加后fftw_cleanup().

[me@mycomputer]$ diff NoCleanup WithCleanup 
2,3c2,3
<     in use at exit: 62,280 bytes in 683 blocks
<   total heap usage: 178,271 allocs, 177,588 frees, 36,617,058 bytes allocated
---
>     in use at exit: 9,008 bytes in 66 blocks
>   total heap usage: 178,271 allocs, 178,205 frees, 36,617,058 bytes allocated
5c5
< 3,304 (24 direct, 3,280 indirect) bytes in 1 blocks are definitely lost in loss record 129 of 131
---
> 3,304 (24 direct, 3,280 indirect) bytes in 1 blocks are definitely lost in loss record 39 of 40
16c16
< 3,304 (24 direct, 3,280 indirect) bytes in 1 blocks are definitely lost in loss record 130 of 131
---
> 3,304 (24 direct, 3,280 indirect) bytes in 1 blocks are definitely lost in loss record 40 of 40
31c31
<    still reachable: 55,672 bytes in 621 blocks
---
>    still reachable: 2,400 bytes in 4 blocks

的数量still reachable退出时使用的字节数显着减少,释放的数量也显着减少mallocs 增加了。但主要错误(3,304 (24 direct, 3,280 indirect) bytes in 1 blocks are definitely lost)仍然存在。


来自FFTW 文档 http://www.fftw.org/doc/Using-Plans.html:

FFTW 的规划器保存了一些其他持久数据,例如积累的智慧和当前配置中可用的算法列表。如果您想释放所有这些并将 FFTW 重置为启动程序时的原始状态,您可以调用:

void fftw_cleanup(void);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 valgrind 检查 fftw3 的相关文章

  • 我可以使用反射更改 C# 中的私有只读字段吗?

    我想知道 由于很多事情都可以使用反射完成 我可以在构造函数完成执行后更改私有只读字段吗 注 只是好奇 public class Foo private readonly int bar public Foo int num bar num
  • 高级 Win32 图像文件 I/O?

    我想在 Windows C 应用程序中将图像文件读入内存 什么是一个相当简单的解决方案 也许类似于 IOS 提供的UIImage 我希望支持合理数量的文件格式 我需要为图像处理的位图提供一些低级访问权限 我在互联网上阅读了很多内容 看起来
  • 如何调试参数化 SQL 查询

    我使用 C 连接到数据库 然后使用 Ad hoc SQL 来获取数据 这个简单的 SQL 查询非常方便调试 因为我可以记录 SQL 查询字符串 如果我使用参数化 SQL 查询命令 有没有办法记录 sql 查询字符串以进行调试 我想就是这样的
  • 处理 LINQ sum 表达式中的 null

    我正在使用 LINQ 查询来查找列的总和 并且在少数情况下该值有可能为空 我现在使用的查询是 int score dbContext domainmaps Where p gt p SchoolId schoolid Sum v gt v
  • Linq Where 本地计数器关闭在 VS watch 中的结果不同

    我尝试删除前 3 个元素array与 LinQWhere扩展功能 这是一个例子 var array new 1 2 3 4 5 6 7 8 9 var count 3 var deletedTest1 0 var test1 array W
  • 对数字进行向上和向下舍入 C++

    我试图让我的程序分别向上和向下舍入数字 例如 如果数字是3 6 我的程序应该四舍五入最接近的数字 4 如果该数字是3 4 它将向下舍入为 3 我尝试使用ceil库获取 3 个项目的平均值 results ceil marks1 marks2
  • 如何避免选择项目时 winforms 树视图图标发生变化

    我正在一个小型 C Winforms 应用程序中尝试树视图 我已经以编程方式将 ImageList 分配给树视图 并且所有节点都很好地显示了它们的图标 but当我单击一个节点时 它的图标会发生变化 变为 ImageList 中的第一个图像
  • 防止复制构造和返回值引用的分配

    如果我有一个函数返回对类实例的引用 但我无法控制其源 比如说list
  • 当格式字符串包含“{”时,String.Format 异常

    我正在使用 VSTS 2008 C Net 2 0 执行以下语句时 String Format 语句抛出 FormatException 有什么想法是错误的吗 这是获取我正在使用的 template html 的位置 我想在 templat
  • 在 C# 中赋值后如何保留有关对象的信息?

    我一直在问我的想法可能是解决方案 https stackoverflow com questions 35254467 is it possible in c sharp to get the attributes attached to
  • C++ Primer 5th Edition 错误 bool 值没有指定最小大小?

    bool 的最小大小不应该是 1 个字节吗 这有点学术性的东西 尽管它们会转换为数字 并且 与其他所有事物一样 它们最终将基本上由计算机内存中的数字表示 但布尔值不是数字 你的bool可以取值true 或值false 即使您确实需要至少 1
  • 为什么 C 函数不能返回数组类型?

    我是 C 语言新手 想知道 为什么 C 函数不能返回数组类型 我知道数组名是数组第一个值的地址 而数组是 C 中的二等公民 您自己已经回答了这个问题 数组是二等公民 C 按值返回 数组不能按值传递 因此不能返回它们 至于为什么数组不能按值传
  • 用 C# 编写的带有点击移动的 WPF 游戏

    我试图将标签网格移动到鼠标的位置 就像冒险游戏中的移动一样 理想情况下 我会在途中删除并重新绘制它们 但是 现在我只想弄清楚如何将 int 转换为厚度或 pointtoscreen 到目前为止我有 player XMove int Mous
  • SSBO 是更大的 UBO?

    我目前正在 OpenGL 4 3 中使用 UBO 进行渲染 以将所有常量数据存储在 GPU 上 诸如材料描述 矩阵等内容 它可以工作 但是 UBO 的小尺寸 我的实现为 64kB 迫使我多次切换缓冲区 减慢渲染速度 我正在寻找类似的方法来存
  • 如何使用 g++ 在 c++ 20 中使用模块?

    我读了这个链接https gcc gnu org wiki cxx modules https gcc gnu org wiki cxx modules并尝试从该网站复制以下示例 我已经知道这个编译器部分支持模块系统 注 我用的是windo
  • 从 C# 中的 .NET SecureString 读取单个字符?

    WPF 的PasswordBox 返回一个SecureString 它对窥探者隐藏密码 问题是你最终必须获得密码的值 而我在网上找到的建议都涉及将值复制到字符串中 这会让你回到窥探者的问题 IntPtr bstr Marshal Secur
  • 如何使复选框不可选择?

    我想知道你是怎么做的CheckBox在c 中无法选择 我认为这会是类似 SetSelectable false 之类的东西 但我似乎看不到该方法 I found CanSelect但这似乎是只读属性 您可以设置自动检查 http msdn
  • C++0x 中的新 unicode 字符

    我正在构建一个 API 它允许我获取各种编码的字符串 包括 utf8 utf16 utf32 和 wchar t 根据操作系统 可能是 utf32 或 utf16 新的 C 标准引入了新类型char16 t and char32 t没有这么
  • 当我读取 500MB FileStream 时出现 OutOfMemoryException

    我使用 Filestream 读取大文件 gt 500 MB 但出现 OutOfMemoryException 任何有关它的解决方案 我的代码是 using var fs3 new FileStream filePath2 FileMode
  • 最后从同一类中的其他构造函数调用构造函数

    我在这里读到可以调用另一个构造函数从同一类中的另一个构造函数调用构造函数 https stackoverflow com questions 829870 calling constructor from other constructor

随机推荐