visual-c++servicememory-leaksmemory-leak-detectorvisual-leak-detector

Attaching Visual leak detector to a process running as windows service


How to use Visual Leak Detector to attach to a process running as a windows service. If someone has used this tool to detect memory leaks for service, please let me know the procedure.

I am including "vld.h" in my source file as in the documentation nothing else.


Solution

    1. Compile your service in debug with vld.h included.
    2. Start your service from the Services Control Manager (no debugger involved yet)
    3. Start Visual Studio - in the Debug Menu select attach to process
    4. Select your process (your service) - make sure to enable native debugging
    5. Stop your service with the debugger still attached and you should get output in the debug window.