-3

Possible Duplicate:
How to Test for Memory Leaks?
how to find memory leak in c++ code/project
How to find a memory leak in C++
Is there a good Valgrind substitute for Windows?

I've got a lot memory leaks in my C++ program. What's the solution (program) to find them?

Community
  • 1
  • 1
Josemi
  • 156
  • 3
  • 15

3 Answers3

4

I like using valgrind. Assuming g++ or clang++, compile your program with -g and try:

valgrind --leak-check=full ./your_executable
thesamet
  • 6,382
  • 2
  • 31
  • 42
2

The best solution is to modernize your program.

  1. Search your programs for new and delete.
  2. Update your program to use smart pointers. Everywhere.
  3. Introducing leaks after that is complete will be "pretty difficult", if you've done it correctly.

If you're on OS X man leaks, the leaks Instrument, or valgrind. You can use these to watch the leak counts drop as the program is modernized ;)

justin
  • 104,054
  • 14
  • 179
  • 226
1

For which OS?

On Linux based systems, Valgrind. Free.

On Windows based systems, Insure++, Purify.... many.

Aravind
  • 1,020
  • 8
  • 4