Valgrind shows memory leak on empty program on Mac OSX 10.8

夙愿已清 提交于 2019-12-05 23:55:35

问题


Valgrind installed using brew.

#include <stdio.h>
#include <stdlib.h>
int main()
{
    return 0;
}

gcc -g -o hello hello.c

valgrind --tool=memcheck --leak-check=yes ./hello


回答1:


This is not a memory leak you need to worry about. ImageLoader is part of the OS X runtime and is responsible for loading binaries and dynamic libraries. It allocates some memory once, during initialization and forgets about it, but it's harmless because it's a small block of memory allocated only once. And it does a bunch of things that Valgrind doesn't like but that aren't incorrect. You should add these to your suppression file.




回答2:


Mac OSX 10.8 support in Valgrind is still limited. ImageLoaderMachO::doInitialization... should be in your suppression file.




回答3:


The other answer is correct, I just happened to have the same problem and had a little trouble creating the suppression file. So, to help others, here is the minimal suppression file I generated for Mac OS X Mountain Lion: https://www.dropbox.com/s/2btyqnf8uesgsis/minimal.supp



来源:https://stackoverflow.com/questions/16210408/valgrind-shows-memory-leak-on-empty-program-on-mac-osx-10-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!