【问题标题】:Using valgrind to find out how an object is still reachable使用 valgrind 找出对象仍然可以访问的方式
【发布时间】:2012-05-07 00:26:21
【问题描述】:

我使用 valgrind 进行内存泄漏检测。有一些代码我预计会产生内存泄漏,但 valgrind 没有检测到它。现在我想知道这个对象以何种方式仍然可以访问(在这种情况下这将是一个问题)。 valgrind 可以输出这些引用吗?

【问题讨论】:

  • 在命令行选项中添加--show-reachable=yes --leak-resolution=high

标签: c memory-leaks valgrind


【解决方案1】:

升级到(尚未发布)3.8.0 SVN 版本的 Valgrind。 然后你有以下 gdbserver 监控命令:

  block_list <loss_record_nr>
        after a leak search, shows the list of blocks of <loss_record_nr>
  who_points_at <addr> [<len>]
        shows places pointing inside <len> (default 1) bytes at <addr>
        (with len 1, only shows "start pointers" pointing exactly to <addr>,
         with len > 1, will also show "interior pointers")

【讨论】:

    猜你喜欢
    • 2011-05-23
    • 1970-01-01
    • 2023-03-29
    • 2015-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-13
    • 1970-01-01
    相关资源
    最近更新 更多