1

I have not used valgrind before, but I need to use it to check memory leak. I ran the following command:

G_SLICE=always-malloc G_DEBUG=gc-friendly  valgrind -v --tool=memcheck --leak-check=full --num-callers=40 --log-file=valgrind.log example1
valgrind: example1: command not found

I followed instructions from this site: http://www.cprogramming.com/debugging/valgrind.html

this is what the example1 file looks like:

#include <stdlib.h>
int main()
{
    char *x = malloc(100); /* or, in C++, "char *x = new char[100] */
    return 0;
}

I know valgrind is installed on my machine, regardless I ran the following command to make sure:

sudo apt-get install valgrind

Can somebody pls. guide me how to get valgrind working....thx!

user1155299
  • 877
  • 5
  • 20
  • 29

1 Answers1

8

You forgot to give it the path to the program you wanted to run! Replace example1 with the path to the executable.

For example:

G_SLICE=always-malloc G_DEBUG=gc-friendly  valgrind -v \
  --tool=memcheck --leak-check=full --num-callers=40 \
  --log-file=valgrind.log ./example1
David Schwartz
  • 179,497
  • 17
  • 214
  • 278