Menu

Leak Verifier tracks resources allocated by DLL or EXE modules. If a resource that was allocated by a DLL or EXE module is not released by the time the module is unloaded, Leak Verifier issues a stop. Leak Verifier is designed to catch virtual reservation, registry, handle, and heap leaks. Leak Verifier is enabled by default.

Caution:
Leak Verifier does not report any resource leaks until the DLL or EXE that allocated the resource is unloaded. To inspect resource allocations in a loaded DLL or EXE, use the !avrf -leak debugger extension.

Leak Verifier is available starting with Windows 7.

Leak Verifier Stops

Properties

The following property is available for the Leak verification layer. To set the property, select the Leak layer in the Application Verifier user interface, and open the Property Window.

Property Description

ExcludeDlls

A comma-separated list of DLLs to exclude from leak verification. Maximum size is 255 characters.

The following command line enables leak verification for myApp.exe and all binaries loaded by myApp.exe except KnownLeaker.dll.

Copy Code
appverif �enable Leak �for myApp.exe �with Leak.ExcludeDlls=KnownLeaker.dll

If you enable leak verification as shown the preceding example, the Leak verification layer still tracks the resources for KnownLeaker.dll, but it does not report any leaks caused by KnownLeaker.dll.

Additional information

You can use the !avrf �leak debugger extension to look at all outstanding resources in a loaded module.

Copy Code
!avrf -leak  [-m <DllName>]  [-r  <ResourceType>] [ -a <address>] [-t] [/?] [-?]

Display all the outstanding resources in myModule.dll.
!avrf -leak -m myModule.dll

Display all the outstanding heap resources in myModule.dll.
!avrf -leak -m myModule.dll -r heap

Display resource with <address> in outstanding heap resources in myModule.dll.
!avrf -leak -m myModule.dll -r heap -a <address> 

Display resource with <address> in outstanding heap resources in myModule.dll with stack trace.
!avrf -leak -m myModule.dll -r heap -a <address> -t

ResourceTypes:

Heap
Heap allocations using Win32 Heap APIs

Local 
Local/Global allocations

CRT 
Heap allocations using C runtime functions

Virtual 
Virtual reservations

BSTR 
BSTR allocations (These resources are tracked, but not reported as leaks by the leak check.)

Registry 
Registry keys

Power
Power notifications

Handle 
Certain types of handles (thread, file, event)