I tried to install Valgrind with brew install Valgrind
and got :
valgrind: This formula either does not compile or function as expected
on macOS
You may use Experimental Version of Valgrind for macOS 10.14.5 Mojave at:
https://github.com/sowson/valgrind
The command to use it is:
brew install --HEAD https://raw.githubusercontent.com/sowson/valgrind/master/valgrind.rb
It is still experimental and needs some work but for simple projects works already... Enjoy!
I have just found a working solution to use VALGRIND on my Mac (Mojave 10.14.6). Just run this command :
brew install --HEAD https://raw.githubusercontent.com/LouisBrunner/valgrind-macos/master/valgrind.rb
(From https://github.com/LouisBrunner/valgrind-macos)
Hope it will work for you.
As of 2019-NOV-30, it is possible to build against OS X 10.14.6 via https://github.com/sowson/valgrind and https://github.com/LouisBrunner/valgrind-macos
However, there are many test failures (see the LouisBrunner link), noise during runs, and SEGVs when running against non-trivial programs: installing is, well, installing. YMMV.
Not a proper solution for macOs, but for the time being, I created a docker image. After installing docker for macOS, this is how to start valgrind:
cd </path/to/source/directory/where/you/want/run/valgrind/with>
curl -O https://raw.githubusercontent.com/biocyberman/ValgrindDocker/master/startValgrind
./startValgrind # this will takes time for the first time, because it needs to fetch docker valgrind image
# you will get a root command prompt inside the docker image.
# do what ever you want
# type 'exit' to quit
addition: I found this one worked for me on my OSX 10.14
brew install --HEAD https://raw.githubusercontent.com/LouisBrunner/valgrind-macos/master/valgrind.rb
A branch that is working to get OSX correct. something to tide us over until we get a real valgrind version fixed.
You can follow alex.m's answer to get valgrind, but if you'r using it on a int main() { return 0; }
program, you'll get many weird errors, and non-existing allocs / free.
To 'hide' these annoying errors, you can follow theses steps (it's more a workaround than a real fix) (based on this wiki page and some research in Valgrind's source code):
int main() { return 0; }
program.valgrind --leak-check=full --show-reachable=yes --error-limit=no --gen-supressions=all --log-file=$YOUR_LOG$ $YOUR_BINARY$
.supp
valgrind file: cat ./$YOUR_LOG$ | ./$YOUR_SCRIPT_FILE$ > minimal.supp
minimal.supp
content at the end of $YOUR_VALGRIND_INSTALLATION_PATH$/lib/valgrind/default.supp
fileAnd you are done! Weird and nonexistent errors will be ignored.
If you also want's to remove the non-existing alloc
s, free
s etc, you can directly edit Valgrind's source code. Or just use heapusage
for leak-tracking