in linux, there is a wonderful tool Valgrind, which detect memory leak. What about visual c++? Is there any free tools? Or is it in build in visual c++?
in linux, there is a wonderful tool Valgrind, which detect memory leak. What about visual c++? Is there any free tools? Or is it in build in visual c++?
yea, i seached msdn, but none is as good as valgrind
Visual Leak Detector - Enhanced Memory Leak Detection for Visual C++
By Dan Moulding
http://www.codeproject.com/tools/visualleakdetector.asp
i tried to download it, but the zip file seems to have problem. do you experienced the problem?
I just downloaded the zip and it works for me.
VLD is quite good, and I've downloaded it several times. Unless you are just unlucky it should work just fine. Barring that, the MSVC leak detector is decent although not as verbose as VLD.
silly me! i didn't register for the code project as member, so i can't d/l it! I have finally d/l it and try to install it. but i got errors when compiling my code.
maybe i have added the files to the wrong place. is it these 2 location?
C:\Program Files\Microsoft Visual Studio\VC98\Include
C:\Program Files\Microsoft Visual Studio\VC98\Lib
i read about visual leak detector for a while on the site given, and i think there is an instruction on how you would install the visual leak detector...
i think you just need to place certain files on those directories
another option not mentioned yet..
fluid studios memory manager (MMGR) is what i had used before valgrind.. i still use it sometimes for quick projects.. i have never heard anything bad about it..
i have never used it in windows.. but im almost positive that it works...
FROM THE WEBPAGE:silly me! i didn't register for the code project as member, so i can't d/l it! I have finally d/l it and try to install it. but i got errors when compiling my code.
maybe i have added the files to the wrong place. is it these 2 location?
C:\Program Files\Microsoft Visual Studio\VC98\Include
C:\Program Files\Microsoft Visual Studio\VC98\Lib
////////////////////////////////////////////////////////////////////
To use VLD with your project, follow these simple steps:
1. Copy the VLD library (*.lib) files to your Visual C++ installation's "lib" subdirectory.
2. Copy the VLD header files (vld.h and vldapi.h) to your Visual C++ installation's "include" subdirectory.
3. In the source file containing your program's main entry point, include the vld.h header file. It's best, but not absolutely required, to include this header before any other header files, except for stdafx.h. If the source file, include stdafx.h, then vld.h should be included after it.
4. If you are running Windows 2000 or earlier, then you will need to copy dbghelp.dll to the directory where the executable being debugged resides.
5. Build the debug version of your project.
////////////////////////////////////////////////////////////////////
I didn't put the libs and include files in Visual C++ installation's "lib" subdirectory. I created a folder called VLD and put them in there and then set the path to them using:
Tools>Options>Projects>VC++ Directories
And put my path in the include and lib files "Show directories for:" section.
When I first tried it I got a few errors because I had put the vld.h after some include files. Once I put them before the other include files the errors cleared up and it worked.
It has been a great tool.
cartoonlarry, i tried your method, but should have the same problem
xpand.obj : error LNK2005: __VLD_configflags already defined in data.obj
expand.obj : error LNK2005: __VLD_maxtraceframes already defined in data.obj
expand.obj : error LNK2005: __VLD_maxdatadump already defined in data.obj
Debug/quasibiclique.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
I have one header file and I add #include <vld.h> in the first line of the header. Is this wrong?
xhi, i tried the mmgr, but also have error
d:\codes\data.h(3) : fatal error C1083: Cannot open include file: 'streamio': No such file or directory
expand.cpp
d:\codes\data.h(3) : fatal error C1083: Cannot open include file: 'streamio': No such file or directory
mmgr.cpp
d:\codes\mmgr.cpp(77) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
Error executing cl.exe.
Creating browse info file...
BSCMAKE: error BK1506 : cannot open file '.\Debug\data.sbr': No such file or directory
Error executing bscmake.exe.
those errors dont ring a bell for me..
i can tell you how i use it.. which as far as i know is the right way..
include the mmgr.h file after the standard includes, iostream string. etc.. but before any of your header files.. include mmgr.h in every header in the project.. and you will need to compile and link mmgr.cpp to the project for it all to work..
maybe you already have this down.. but its worth mentioning..
example usage
that is how i used it in an old file..Code:#ifndef ANIMATEDIOS_H #define ANIMATEDIOS_H #include <SDL/SDL.h> #include <iostream> #include <string> #include "mmgr.h" #include "IOS.h"
good luck..
Have you tried to see if it will work with a very simple test app.cartoonlarry, i tried your method, but should have the same problem
I did a quick test with them using Visual C++ installation's "include" and "lib" subdirectories:
I put vld.h and vldapi.h in C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
I put vld.lib, vldmt.lib, and vldmtdll.lib in C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib
I created a very simple Win32 Console project:
After running in Debug mode here are my results:Code:#include <vld.h> int main() { int *leak = new int; return 0; }
Visual Leak Detector Version 1.0 installed (single-threaded static).
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 46 at 0x00896BF0: 4 bytes ----------
Call Stack:
c:\dev\vldtest\main.cpp (5): main
f:\vs70builds\3077\vc\crtbld\crt\src\crt0.c (259): mainCRTStartup
0x7C816D4F (File and line number not available): RegisterWaitForInputIdle
Data:
CD CD CD CD ........ ........
Visual Leak Detector detected 1 memory leak.
'VLDTest.exe': Unloaded 'C:\WINDOWS\SYSTEM32\dbghelp.dll'
'VLDTest.exe': Unloaded 'C:\WINDOWS\SYSTEM32\version.dll'
Visual Leak Detector is now exiting.
The program '[3540] VLDTest.exe: Native' has exited with code 0 (0x0).
/////////////////////////////////////////////////////////
I have also used it in large applications and haven't had any problems. I usually put the VLD include in my main.cpp just before my other includes.
Hope this helps.