How can I diagnose why my FreeLibrary isn’t freeing the library?

Raymond Chen

Raymond

A customer had some code that called Free­Library, and they expected the library to be freed, but it wasn’t happening. They suspect that there was an unmatched call to Load­Library and was wondering if there were any diagnostic tools that would help them find it.

Application Verifier to the rescue.

Application Verifier maintains a history of module loads and unloads, and you can use the !avrf -dlls debugger extension to view that log. For each module that is loaded and unloaded, it records a stack trace of the Load­Library and Free­Library.

The customer reported back that this debugger extension found the problem. Their code used the HKEY_PERFORMANCE_DATA registry key to read some performance counters, and opening the performance counter was triggering an additional DLL load.

Raymond Chen
Raymond Chen

Follow Raymond   

0 comments

Comments are closed.