[英]Valgrind reports leaked memory on OS X 10.8.1
我在Mountain Lion的OS X 10.8.1上使用Valgrind版本3.8.0。 關於與10.8.1的兼容性, Valgrind的網站說(italics mine):
Valgrind 3.8.0適用於 {x86,amd64} -darwin(Mac OS X 10.6和10.7,支持10.8)。
那么,我知道10.8.1只有“有限的支持”。 盡管如此, 這個錯誤報告說(斜體礦):
這個(最新的3.8.0版本)使Valgrind編譯並能夠在OSX 10.8上運行小程序。 但是請注意,它仍然使用更大的應用程序斷言,並且根本沒有正確檢查32位程序(Memcheck錯過了大多數錯誤)。
好沒關系。 因此,如果氣質,Valgrind應該在10.8.1上工作。 所以現在我的問題是:
我能夠很好地讓Valgrind在10.8.1上編譯,但是當我在幾個小C程序上運行它時,我看到了一些奇怪的結果。 為了嘗試減少問題的可能原因,我最終編寫了以下“程序”:
int main () {
return 0;
}
我會說,不是很令人興奮,而且很少有蟲子的余地。 然后,我編譯並通過Valgrind運行它:
gcc testC.c
valgrind ./a.out
這是我的輸出:
==45417== Command: ./a.out
==45417==
==45417== WARNING: Support on MacOS 10.8 is experimental and mostly broken.
==45417== WARNING: Expect incorrect results, assertions and crashes.
==45417== WARNING: In particular, Memcheck on 32-bit programs will fail to
==45417== WARNING: detect any errors associated with heap-allocated data.
==45417==
--45417-- ./a.out:
--45417-- dSYM directory is missing; consider using --dsymutil=yes
==45417==
==45417== HEAP SUMMARY:
==45417== in use at exit: 58,576 bytes in 363 blocks
==45417== total heap usage: 514 allocs, 151 frees, 62,442 bytes allocated
==45417==
==45417== LEAK SUMMARY:
==45417== definitely lost: 8,624 bytes in 14 blocks
==45417== indirectly lost: 1,168 bytes in 5 blocks
==45417== possibly lost: 4,925 bytes in 68 blocks
==45417== still reachable: 43,859 bytes in 276 blocks
==45417== suppressed: 0 bytes in 0 blocks
==45417== Rerun with --leak-check=full to see details of leaked memory
==45417==
==45417== For counts of detected and suppressed errors, rerun with: -v
==45417== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
我知道Valgrind還沒有准備好在10.8.1的黃金時段。 盡管如此,我希望能夠在這里使用它 - 我只需要在小程序中使用它,並且沒有任何關於結果的任務至關重要。 但顯然,它報告了一個似乎不太可能泄漏的程序中的大量泄漏。 從而:
我該怎么做才能解決這個問題?
其他信息:
-g
標志進行編譯然后運行到Valgrind(以解決dSYM directory is missing
錯誤)確實會導致該錯誤消失,但不會更改報告的大量內存泄漏問題。 Valgrind后備箱似乎已經改進到現在可以使用的程度。 我還沒有看到它崩潰,但確實有很多誤報,可以使用抑制文件處理。
現在,我的抑制文件如下所示:
# OS X 10.8 isn't supported, has a bunch of 'leaks' in the loader
{
osx_1080_loader_false_positive_1
Memcheck:Leak
...
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListE
...
}
{
osx_1080_loader_false_positive_2
Memcheck:Leak
...
fun:_ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE
...
}
{
osx_1080_loader_false_positive_3
Memcheck:Leak
...
fun:map_images_nolock
...
}
{
osx_1080_loader_false_positive_4
Memcheck:Leak
...
fun:_objc_fetch_pthread_data
fun:_ZL27_fetchInitializingClassLista
fun:_class_initialize
fun:_class_initialize
fun:_class_initialize
fun:_class_initialize
fun:prepareForMethodLookup
fun:lookUpMethod
fun:objc_msgSend
fun:_libxpc_initializer
fun:libSystem_initializer
}
我也在mac osx 10.8上運行來自macports的valgrind。 它運行沒有崩潰,但確實產生了一些瘋狂的結果,如此stackoverflow帖子中的那些, 來自Valgrind的混亂輸出顯示間接丟失的內存泄漏但沒有明確丟失或可能丟失 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.