分配完全不受您的控制;免费对你来说同样是不可能的。这应该被添加到已知、检测到、记录但被忽略的项目列表中(行话是“抑制”)。
当我在 MacOS X 10.7.2 上的 valgrind 3.7.0 下运行程序时,我得到如下摘要:
==71989==
==71989== HEAP SUMMARY:
==71989== in use at exit: 6,191 bytes in 33 blocks
==71989== total heap usage: 33 allocs, 0 frees, 6,191 bytes allocated
==71989==
==71989== LEAK SUMMARY:
==71989== definitely lost: 0 bytes in 0 blocks
==71989== indirectly lost: 0 bytes in 0 blocks
==71989== possibly lost: 0 bytes in 0 blocks
==71989== still reachable: 6,191 bytes in 33 blocks
==71989== suppressed: 0 bytes in 0 blocks
==71989== Rerun with --leak-check=full to see details of leaked memory
==71989==
==71989== For counts of detected and suppressed errors, rerun with: -v
==71989== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 1 from 1)
这是来自一个没有显式内存分配的程序 -printf()
可能会触发一些分配,但大部分字节是在系统库中分配的。您显然为回溯设置了比正常值更深的值(--num-callers=N
).
查看手册如何正确添加抑制记录,但是valgrind --help
offers:
--num-callers=<number> show <number> callers in stack traces [12]
--error-limit=no|yes stop showing new errors if too many? [yes]
--error-exitcode=<number> exit code to return if errors found [0=disable]
--show-below-main=no|yes continue stack traces below main() [no]
--suppressions=<filename> suppress errors described in <filename>
--gen-suppressions=no|yes|all print suppressions for errors? [no]
所以,你可以获得valgrind
生成抑制字符串以添加到文件中,然后在后续运行中使用。
Extra options read from ~/.valgrindrc, $VALGRIND_OPTS, ./.valgrindrc