Valgrind - 抑制文件过于笼统?

时间:2016-02-11 20:24:52

标签: c memory-leaks valgrind suppress-warnings suppression

我是 valgrind 的新手,首先要注意的是,OS X El Capitan上的标准C-Library似乎泄漏了内存(可能丢失了) 。在稍微阅读之后,情况并非如此,并且可以使用抑制文件从 valgrind泄漏摘要中排除system-lib。

我生成了一个这样的抑制文件(通过运行一个简单的程序)并将错误添加到抑制文件中。它看起来像这样:

osx_el_capitan_c_lib.supp

{
  <osx_el_capitan_c_lib>
   Memcheck:Leak
   match-leak-kinds: possible
   fun:malloc_zone_malloc
   fun:_objc_copyClassNamesForImage
   fun:_ZL9protocolsv
   fun:_Z9readClassP10objc_classbb
   fun:gc_init
   fun:_ZL33objc_initializeClassPair_internalP10objc_classPKcS0_S0_
   fun:layout_string_create
   fun:_ZL12realizeClassP10objc_class
   fun:_ZL22copySwiftV1MangledNamePKcb
   fun:_ZL22copySwiftV1MangledNamePKcb
   fun:_ZL22copySwiftV1MangledNamePKcb
   fun:_ZL22copySwiftV1MangledNamePKcb
}

现在我有几个问题:

  • 这个文件是否有可能抑制我的实际代码(不是system-libs)的泄漏?我测试了一点肯定泄漏/没有泄漏代码,它似乎工作正常。但我怎么能确定?
  • 默认输出电流如下(绝对不会泄漏):

    
        ==37004== Memcheck, a memory error detector
        ==37004== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
        ==37004== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
        ==37004== Command: ./val.o
        ==37004== 
        ==37004== 
        ==37004== HEAP SUMMARY:
        ==37004==     in use at exit: 22,100 bytes in 187 blocks
        ==37004==   total heap usage: 271 allocs, 84 frees, 28,340 bytes allocated
        ==37004== 
        ==37004== LEAK SUMMARY:
        ==37004==    definitely lost: 0 bytes in 0 blocks
        ==37004==    indirectly lost: 0 bytes in 0 blocks
        ==37004==      possibly lost: 0 bytes in 0 blocks
        ==37004==    still reachable: 0 bytes in 0 blocks
        ==37004==         suppressed: 22,100 bytes in 187 blocks
        ==37004== 
        ==37004== For counts of detected and suppressed errors, rerun with: -v
        ==37004== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 18 from 18)
    
    
    正如您所看到的,抑制文件现在非常有用(没有字节显示为丢失等)。但是堆摘要不会受到它看起来的抑制文件的影响(显示allocs / mallocs - 它们发生在我的代码之外)并且泄漏摘要显示被抑制这是自己的领域。有没有办法可以禁用此字段(标志或其他内容)并抑制堆摘要中的(allocs / mallocs在我的代码之外)?

0 个答案:

没有答案