For simple projects in C You can install valgrind on mac by giving the following command in terminal (Note for simple projects in C only since compiling official valgrind code on Mac OS Mojave is very cumbersome and unreliable process, So this is a shortcut.)
brew install --HEAD https://raw.githubusercontent.com/sowson/valgrind/master/valgrind.rb
Bonus: using valgrind on mac
First compile your code using gcc as follows
gcc -Wall -pedantic -g main.c -o main
Note the use of -g option because we would like valgrind to atleast guide us where the memory leak could be
valgrind --tool=memcheck --leak-check=yes ./main
Look for main.c in your results which will show line number where errors could be.
Cheers!
No comments:
Post a Comment