Valgrind的MAC OS纪念品泄漏 [英] valgrind mac os mem leak

查看:99
本文介绍了Valgrind的MAC OS纪念品泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我在我的Mac OS X 10.6的valgrind安装并试图对其进行测试。它原来是系统中的怪异的内存泄漏。我所做的只是创建简单的C文件,该文件得到一些堆内存,并立即释放它。当我跑Valgrind的这表明像这样

  Realfrees-的MacBook-PRO:C $ Realfree的valgrind --tool = MEMCHECK --leak检查= YES  - 显示,可达= YES ./a.out
== == 2621 MEMCHECK,内存错误检测
== == 2621版权所有(C)2002-2010,和GNU GPL的,Julian Seward写等。
== == 2621 Valgrind的使用,3.6.0和LibVEX;与-h版权信息重新运行
== == 2621命令:./a.out
== == 2621
--2621-- ./a.out:
--2621--的dSYM目录是丢失;考虑使用--dsymutil = YES
== == 2621
== == 2621 HEAP摘要:
== == 2621使用在出口处:在1块88个字节
== == 2621总堆的使用情况:2 allocs,1的FreeS,92字节分配
== == 2621
== == 2621在88块1字节仍处于负的战绩1 1可达
== == 2621在0x100010915:的malloc(vg_replace_malloc.c:236)
== == 2621通过0x1000260EB:get_or_create_key_element(以/usr/lib/libSystem.B.dylib)
== == 2621通过0x100026008:_keymgr_get_and_lock_processwide_ptr_2(以/usr/lib/libSystem.B.dylib)
== == 2621通过0x100025FCF:__keymgr_initializer(以/usr/lib/libSystem.B.dylib)
== == 2621通过0x1000245E7:libSystem_initializer(以/usr/lib/libSystem.B.dylib)
== == 2621通过0x7FFF5FC0D4FF:ImageLoaderMachO :: doModInitFunctions(ImageLoader的:: LinkContext常量和放大器;)(在/ usr / lib中/ dyld的)
== == 2621通过0x7FFF5FC0BCEB:ImageLoader的:: recursiveInitialization(ImageLoader的:: LinkContext常量和放大器;,无符号整数)(在/ usr / lib中/ dyld的)
== == 2621通过0x7FFF5FC0BC9C:ImageLoader的:: recursiveInitialization(ImageLoader的:: LinkContext常量和放大器;,无符号整数)(在/ usr / lib中/ dyld的)
== == 2621通过0x7FFF5FC0BDA5:ImageLoader的:: runInitializers(ImageLoader的:: LinkContext常量和放大器;)(在/ usr / lib中/ dyld的)
== == 2621通过0x7FFF5FC020EE:dyld的:: initializeMainExecutable()(在/ usr / lib中/ dyld的)
== == 2621通过0x7FFF5FC06980:dyld的:: _主(macho_header const的*,无符号长,整型,字符常量**,字符常量**,字符常量**)(在/ usr / lib中/ dyld的)
== == 2621通过0x7FFF5FC016D1:dyldbootstrap ::开始(macho_header const的*,整型,字符常量**长)(在/ usr / lib中/ dyld的)
== == 2621
== == 2621泄漏摘要:
== == 2621肯定丢失:0字节0块
== == 2621失去了间接:0字节0块
== == 2621可能丢失:0字节0块
== == 2621仍可达:在1块88个字节
== == 2621燮pressed:0字节0块
== == 2621
== == 2621对于检测燮pressed错误计数,重新运行:-v
== == 2621错误摘要:从0 0上下文错误(SUP pressed:0 0)

在这里的记忆一定量仍可达。任何想法如何解决?或者这是正常的MAC

P.S。我用命令ls的valgrind跑-l,它显示块的一堆仍然到达。
我不知道这是在Mac上正常的行为。
下面是命令行的结果的valgrind --tool = MEMCHECK ls -l命令:

  == == 2734
== == 2734 HEAP摘要:
== == 2734使用在出口处:在52块118331字节
== == 2734总堆的使用情况:1253 allocs,1,201的FreeS,214242字节分配
== == 2734
== == 2734泄漏摘要:
== == 2734肯定丢失:0字节0块
== == 2734失去了间接:0字节0块
== == 2734可能丢失:0字节0块
== == 2734到达尚:在52块118331字节
== == 2734燮pressed:0字节0块
== == 2734与重新运行--leak检查=全看到内存泄露的细节
== == 2734
== == 2734对于检测燮pressed错误计数,重新运行:-v
== == 2734错误摘要:从0 0上下文错误(SUP pressed:0 0)


解决方案

和适用于Mac OS X Lion中,你应该使用这个SUP pression文件:的http://valgrind-variant.google$c$c.com/svn-history/trunk/valgrind/darwin11.supp

Today I installed valgrind on my Mac os x 10.6 and tried to test it out. And it turned out to be weird memory leaks in the system. What I did was just create simple c file that get some heap memory and immediately free it. When I ran valgrind it showed something like this

Realfrees-MacBook-Pro:C Realfree$ valgrind --tool=memcheck --leak-check=yes --show-reachable=yes ./a.out 
==2621== Memcheck, a memory error detector
==2621== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==2621== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright info
==2621== Command: ./a.out
==2621== 
--2621-- ./a.out:
--2621-- dSYM directory is missing; consider using --dsymutil=yes
==2621== 
==2621== HEAP SUMMARY:
==2621==     in use at exit: 88 bytes in 1 blocks
==2621==   total heap usage: 2 allocs, 1 frees, 92 bytes allocated
==2621== 
==2621== 88 bytes in 1 blocks are still reachable in loss record 1 of 1
==2621==    at 0x100010915: malloc (vg_replace_malloc.c:236)
==2621==    by 0x1000260EB: get_or_create_key_element (in /usr/lib/libSystem.B.dylib)
==2621==    by 0x100026008: _keymgr_get_and_lock_processwide_ptr_2 (in /usr/lib/libSystem.B.dylib)
==2621==    by 0x100025FCF: __keymgr_initializer (in /usr/lib/libSystem.B.dylib)
==2621==    by 0x1000245E7: libSystem_initializer (in /usr/lib/libSystem.B.dylib)
==2621==    by 0x7FFF5FC0D4FF:  ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) (in /usr/lib/dyld)
==2621==    by 0x7FFF5FC0BCEB: ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int) (in /usr/lib/dyld)
==2621==    by 0x7FFF5FC0BC9C: ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int) (in /usr/lib/dyld)
==2621==    by 0x7FFF5FC0BDA5: ImageLoader::runInitializers(ImageLoader::LinkContext const&) (in /usr/lib/dyld) 
==2621==    by 0x7FFF5FC020EE: dyld::initializeMainExecutable() (in /usr/lib/dyld)
==2621==    by 0x7FFF5FC06980: dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**) (in /usr/lib/dyld)
==2621==    by 0x7FFF5FC016D1: dyldbootstrap::start(macho_header const*, int, char const**, long) (in /usr/lib/dyld)
==2621== 
==2621== LEAK SUMMARY:
==2621==    definitely lost: 0 bytes in 0 blocks
==2621==    indirectly lost: 0 bytes in 0 blocks
==2621==      possibly lost: 0 bytes in 0 blocks
==2621==    still reachable: 88 bytes in 1 blocks
==2621==         suppressed: 0 bytes in 0 blocks
==2621== 
==2621== For counts of detected and suppressed errors, rerun with: -v
==2621== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

where a certain amount of memory is still reachable. Any idea how to fix? or this is normal for mac

P.S. I ran valgrind with command ls -l, and it showed bunch of block that were still reachable. I'm not sure this is normal behavior on mac. below is result of command line "valgrind --tool=memcheck ls -l":

==2734== 
==2734== HEAP SUMMARY:
==2734==     in use at exit: 118,331 bytes in 52 blocks
==2734==   total heap usage: 1,253 allocs, 1,201 frees, 214,242 bytes allocated
==2734== 
==2734== LEAK SUMMARY:
==2734==    definitely lost: 0 bytes in 0 blocks
==2734==    indirectly lost: 0 bytes in 0 blocks
==2734==      possibly lost: 0 bytes in 0 blocks
==2734==    still reachable: 118,331 bytes in 52 blocks
==2734==         suppressed: 0 bytes in 0 blocks
==2734== Rerun with --leak-check=full to see details of leaked memory
==2734== 
==2734== For counts of detected and suppressed errors, rerun with: -v
==2734== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

解决方案

And for Mac OS X Lion, you should use this suppression file : http://valgrind-variant.googlecode.com/svn-history/trunk/valgrind/darwin11.supp

这篇关于Valgrind的MAC OS纪念品泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆