{"id":97035,"date":"2017-09-15T07:00:00","date_gmt":"2017-09-15T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=97035"},"modified":"2019-03-13T01:16:52","modified_gmt":"2019-03-13T08:16:52","slug":"20170915-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20170915-00\/?p=97035","title":{"rendered":"How can I diagnose why my FreeLibrary isn&#8217;t freeing the library?"},"content":{"rendered":"<p>A customer had some code that called <code>Free&shy;Library<\/code>, and they expected the library to be freed, but it wasn&#8217;t happening. They suspect that there was an unmatched call to <code>Load&shy;Library<\/code> and was wondering if there were any diagnostic tools that would help them find it. <\/p>\n<p>Application Verifier to the rescue. <\/p>\n<p>Application Verifier maintains a history of module loads and unloads, and you can use <a HREF=\"https:\/\/docs.microsoft.com\/windows-hardware\/drivers\/debugger\/-avrf\">the <code>!avrf -dlls<\/code><\/a> debugger extension to view that log. For each module that is loaded and unloaded, it records a stack trace of the <code>Load&shy;Library<\/code> and <code>Free&shy;Library<\/code>. <\/p>\n<p>The customer reported back that this debugger extension found the problem. Their code used the <code>HKEY_<\/code><code>PERFORMANCE_<\/code><code>DATA<\/code> registry key to read some performance counters, and opening the performance counter was triggering an additional DLL load. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Application Verifier to the rescue.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-97035","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Application Verifier to the rescue.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/97035","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=97035"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/97035\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=97035"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=97035"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=97035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}