Mar 7, 2012 - Typically that last part needs to be done as root: sudo make install. And to try apt-get instead of compiling source, leave off the version.
Press Command+Space and type Terminal and press enter/return key.
Run in Terminal app: ruby -e '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)' < /dev/null 2> /dev/null and press enter/return key. If the screen prompts you to enter a password, please enter your Mac's user password to continue. When you type the password, it won't be displayed on screen, but the system would accept it. So just type your password and press ENTER/RETURN key. Then wait for the command to finish.
Run: brew install valgrind
Done! You can now use valgrind.
Similar Software for Mac
What is Valgrind?[edit]
Valgrind (downloadable here) is a utility for debugging programs for the x86 and x86-64 Linux platforms. It has recently become highly popular as it can be used to easily track down memory management and threading bugs that are hard to track down otherwise.
How to install it[edit]
There is a 'generic' option, available on most systems, which involves compiling:
On most Linux distributions, however, you can use the package management system. For example, in Debian GNU/Linux (and derivatives) simply run:
How to use it[edit]
Valgrind can be run simply by prefixing the command line that you run with valgrind
This simple test will check that the memory accesses with in the program are correct. Do not be surprised when you get messages about code that you know is not a problem. This program tests every access and some programs are forgiving about existing errors. It is always worth fixing these extra errors because they will be impossible to track down when they do cause a breakage in code.
You may prefer to run valgrind and log to a text file, with the following options:
How it works[edit]
Valgrind is essentially an x86 machine-code interpreter. In fact it runs as a just-in-time compiler converting the machine code to an internal language, instrumenting that language and then code-generatingfrom that language. Valgrind instruments the code to monitor memory allocation, deallocation, writes and reads, which lets it hold a bit-map of memory state. hence it can report attempts to read data from memory that has never yet been written, or using recently-freed memory. Under Valgrind a program will take something like 2-10 times longer than when run uninstrumented.
Callgrind is a related program that uses the same x86 interpreter technology to instrument the code to log routine calls and generate a file that can be analyzed to show time spent in various routines and the call paths involved.
Retrieved from 'https://en.wikibooks.org/w/index.php?title=Valgrind&oldid=3459399'