Is there a simple memory debugger for Windows that (a) is free and (b) works?

I tried to debug a subtle memory issue in a large project. These were weeks, and I still could not find him. My program crashes after starting for a certain time. As a result, I tried to get a memory debugger. Here are the options I reviewed / tried:

  • IBM Purify - successfully detects a memory leak, but asks me to pay money to find out where it is.
  • Valgrind - I heard good things about this program, but it is for Linux, and I would have to transfer my entire project on top of
  • MPatrol - again this is mainly for linux. The Windows version is for MingGW, and I'm using Visual Studio. I found the binaries for VC ++ online and followed the instructions, but the program refused to display the log files.
  • Application Verifier - throws a random breakpoint at startup, requests a nonexistent source file (sdk.cpp) in Visual Studio, and then gives this error every time, regardless of what exe I attach it to: "First chance access violation for the current stack trace "
  • WinDbg - I don’t even know if this program does what I think. Always gives "ERROR: file with symbol not found". And it looks like it does nothing when I run my exe.

I searched all these errors on Google for several hours to no avail. The relevant documentation for these packages does not seem to contain information about my specific problems. Is there a debugger that works? Do I need to port my program to Linux? Can someone point me in the direction of good documentation regarding memory debugging? Any help would be greatly appreciated. Thanks in advance!

Edit:

Thanks for all the answers. I understand that the problem with the crash is probably not a memory leak. After working for a while, he just freezes. There is no error message. This usually happens when writing to cout. So I realized that it was some corruption of memory. I think I will consider the deeper possibilities of the visual studio. In fact, using the trial version of Purify, I found several errors, but I do not want to cough up to $ 1,600 for the full version. In the worst case, I port it to Linux. Thanks again for the help.

Edit 2:

After some testing with Purify, it looks like there are no more memory errors in my program. I noticed that the program freezes when I click on it, as on the command line itself. So I'm going to suggest that this is not a problem with my code, but rather a way to interact with text selection. (Edit 2a: facepalm should make the choice) Thanks again for the help.

In the future, where can I learn about more complex debugging? I used breakpoints and watched the expressions, but at school they only teach the language itself. Do I need to learn the x86 build?

+4
source share
4 answers

Visual Studio enables memory leak detection in the debug version of the C libraries. For information, see this page on MSDN .

But you do not seem to be sure that the accident is due to a memory leak. In fact, memory leaks usually do not lead to crashes (unless an accident occurs because the system is completely out of memory). You may have leaks, but they may not be related to the crash.

Have you tried looking at crash with VS debugger? Many times this will give you an idea of ​​what problems you are facing. If you get crashes, I suspect that you are likely to corrupt the memory, for example, by running the end of the allocated memory block or using the memory after it is released.

This article has some ideas on how to approach memory problems, and this page lists some free and commercial memory debuggers, some of which are not on your list.

Good luck.

+3
source

I use a visual leak detector. It detects memory leaks and gives you a call stack for them. He works with a visual studio and is pretty reliable. You can take it from here - http://vld.codeplex.com/
I don’t know, this is exactly what you are looking for, but it is useful.

+1
source

OllyDbg is not on your list and works great

edit: deep into the search, it shows something free, which allows you to control a bunch of the process in a simpler way than the traditional debugger on Windows-based systems.

+1
source

Perhaps Gdb and Valgrind were ported to Windows?

And if your application does not apply to windows or uses libraries (for example, Qt) that have been ported to both Windows and Linux, you might consider debugging them in Linux.

+1
source

Source: https://habr.com/ru/post/1379590/


All Articles