<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic It would appear that the in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069529#M119160</link>
    <description>&lt;P&gt;It would appear that the unload request is never received. It logs the load, but not the unload.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Jan 2016 21:25:30 GMT</pubDate>
    <dc:creator>Steve_R_2</dc:creator>
    <dc:date>2016-01-04T21:25:30Z</dc:date>
    <item>
      <title>freelibrary fails to unload dll</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069519#M119150</link>
      <description>&lt;P style="font-size: 13.008px; line-height: 19.512px;"&gt;I have a couple of fortran dll's (Intel® Parallel Studio XE 2016 Update 1 Composer Edition for Fortran Windows) that get loaded into a c++ program. After they're done I'd like to unload the dll's. One of them unloads fine. The other won't. Even if I put the whole operation on a separate thread, doing the FreeLibrary and closing the thread, still leaves the one dll (and the dll's that it loads) attached to the process.&lt;/P&gt;

&lt;DIV style="font-size: 13.008px; line-height: 19.512px;"&gt;&amp;nbsp;&lt;/DIV&gt;

&lt;DIV style="font-size: 13.008px; line-height: 19.512px;"&gt;For the dll in question I tried doing a FreeLibrary right after the LoadLibrary, and it still fails.&lt;/DIV&gt;

&lt;DIV style="font-size: 13.008px; line-height: 19.512px;"&gt;&amp;nbsp;&lt;/DIV&gt;

&lt;DIV style="font-size: 13.008px; line-height: 19.512px;"&gt;So, what's making the dll so "sticky" and what can I try to fix it?&lt;/DIV&gt;</description>
      <pubDate>Wed, 30 Dec 2015 23:52:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069519#M119150</guid>
      <dc:creator>Steve_R_2</dc:creator>
      <dc:date>2015-12-30T23:52:05Z</dc:date>
    </item>
    <item>
      <title>If you read the MSDN</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069520#M119151</link>
      <description>&lt;P&gt;If you read the &lt;A href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms683152(v=vs.85).aspx"&gt;MSDN description of FreeLibrary&lt;/A&gt;, it says that the call "decrements a reference count" and that the library isn't unloaded until the count goes to zero. The article has additional details that may be of interest. There's nothing particularly "sticky" about a Fortran DLL. Perhaps you have some other reference to it in the program. A call to GetModuleHandle before you call LoadLibrary would be instructive.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 02:13:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069520#M119151</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-12-31T02:13:45Z</dc:date>
    </item>
    <item>
      <title>Thanks. I was aware of this</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069521#M119152</link>
      <description>&lt;P&gt;Thanks. I was aware of this and have tried various things, like a loop to do multiple frees. I've watched when things get loaded in ProcessMonitor, and kept track of what dll's get loaded etc. so, I know it's only being loaded once.&lt;/P&gt;

&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;

&lt;DIV&gt;I tried the load/free from a different program, duplicating the code in the first that does the same, but minus the other parts of the main program that have nothing to do with this part, and it works ok. The 2 dll's load and unload fine, and can even perform what they are supposed to do, and still unload. So, there is something, that I have yet to find, that keeps the dll loaded in the one case.&lt;/DIV&gt;</description>
      <pubDate>Thu, 31 Dec 2015 17:34:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069521#M119152</guid>
      <dc:creator>Steve_R_2</dc:creator>
      <dc:date>2015-12-31T17:34:33Z</dc:date>
    </item>
    <item>
      <title>Does any part of the program</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069522#M119153</link>
      <description>&lt;P&gt;Does any part of the program link against this DLL? Does GetrModuleHandle return a handle to the DLL if you call it at the start of the program?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 18:37:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069522#M119153</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2015-12-31T18:37:16Z</dc:date>
    </item>
    <item>
      <title>No. Previously at this point,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069523#M119154</link>
      <description>&lt;P&gt;No. Previously at this point, the program launched what are now dll's as a separate process. But, for various reasons, we're trying to turn what was a program into dll's. But, I checked, and just before the load, GetModuleHandle returns a null.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 21:17:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069523#M119154</guid>
      <dc:creator>Steve_R_2</dc:creator>
      <dc:date>2015-12-31T21:17:59Z</dc:date>
    </item>
    <item>
      <title>When you invoke FreeLibrary,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069524#M119155</link>
      <description>&lt;P&gt;When you invoke FreeLibrary, does it return zero or nonzero? If zero, what does GetLastError say? If zero, have you tried zapping the DLL with UnmapViewOfFile?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jan 2016 00:15:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069524#M119155</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2016-01-01T00:15:18Z</dc:date>
    </item>
    <item>
      <title>FreeLibrary returns true. I</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069525#M119156</link>
      <description>&lt;P&gt;FreeLibrary returns true. I've tried UnMapView of file, and the dll disappears from the process. But, then I get exceptions in other places. If I let the dll actually do what it's supposed to do, then even though all files have been explicitly closed, when I use UnMap, several files are still said to be owned by the process and I get an exception using the system routine&amp;nbsp;DeleteDirectory.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 17:13:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069525#M119156</guid>
      <dc:creator>Steve_R_2</dc:creator>
      <dc:date>2016-01-04T17:13:33Z</dc:date>
    </item>
    <item>
      <title>Have you tried putting in a</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069526#M119157</link>
      <description>&lt;P&gt;Have you tried putting in a DllMain entry point that logs the load and unload? It would be interesting to see if the unload request comes through.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 17:39:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069526#M119157</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2016-01-04T17:39:06Z</dc:date>
    </item>
    <item>
      <title>I'm not entirely sure how I</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069527#M119158</link>
      <description>&lt;P&gt;I'm not entirely sure how I write a DllMain in fortran. Do I just do -&amp;nbsp;&lt;/P&gt;

&lt;DIV&gt;
	&lt;DIV&gt;subroutine DllMain&lt;/DIV&gt;

	&lt;DIV&gt;&amp;nbsp;!DEC$ ATTRIBUTES DLLEXPORT::DllMain&lt;/DIV&gt;

	&lt;DIV&gt;&amp;nbsp;...&lt;/DIV&gt;

	&lt;DIV&gt;&amp;nbsp;return&lt;/DIV&gt;

	&lt;DIV&gt;&amp;nbsp;end&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 04 Jan 2016 20:11:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069527#M119158</guid>
      <dc:creator>Steve_R_2</dc:creator>
      <dc:date>2016-01-04T20:11:32Z</dc:date>
    </item>
    <item>
      <title>function DllMain (hinstDLL,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069528#M119159</link>
      <description>&lt;PRE class="brush:fortran;"&gt;function DllMain (hinstDLL, fdwReason, lpvReserved) bind(C,name="DllMain")
use IFWINTY
integer(BOOL) :: DllMain
!DEC$ ATTRIBUTES STDCALL, DLLEXPORT :: DllMain
integer(HANDLE), value, intent(IN) :: hinstDLL
integer(DWORD), value, intent(IN) :: fdwReason
integer(LPVOID), value, intent(IN) :: lpvReserved

if (fdwReason == DLL_PROCESS_ATTACH) then
   ... Loaded
else if (fdwReason == DLL_PROCESS_DETACH) then
   ... Unloaded
end if

DllMain = TRUE
end function DllMain&lt;/PRE&gt;

&lt;P&gt;You'll want to be careful with what you do in this procedure. No Fortran I/O, for example.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 20:19:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069528#M119159</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2016-01-04T20:19:16Z</dc:date>
    </item>
    <item>
      <title>It would appear that the</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069529#M119160</link>
      <description>&lt;P&gt;It would appear that the unload request is never received. It logs the load, but not the unload.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 21:25:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069529#M119160</guid>
      <dc:creator>Steve_R_2</dc:creator>
      <dc:date>2016-01-04T21:25:30Z</dc:date>
    </item>
    <item>
      <title>That suggests to me there is</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069530#M119161</link>
      <description>&lt;P&gt;That suggests to me there is an extra reference somewhere. I have no clue as to how to diagnose that.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 23:20:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069530#M119161</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2016-01-04T23:20:43Z</dc:date>
    </item>
    <item>
      <title>My mind is a little foggy on</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069531#M119162</link>
      <description>&lt;P&gt;My mind is a little foggy on this, but I seem to recall there is an option (somewhere that escapes me) that you can set (or unset) that causes a pre-load of dependent libraries (IOW at program load time as opposed to at first call). Possibly this is inadvertently set.&lt;/P&gt;

&lt;P&gt;Note, if this is set, then, the return stack from Process Attach may indicate that "main" (tmain, ...) is not on stack. ** caviat ** on C++ a static ctor,, which runs before main, may also affect the load. So you will have to discern this too.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 13:54:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069531#M119162</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2016-01-05T13:54:13Z</dc:date>
    </item>
    <item>
      <title>I tried rebuilding the dll</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069532#M119163</link>
      <description>&lt;P&gt;I tried rebuilding the dll that uses these dll's, and things work in debug mode from inside visual studio. But, using the debug dll, or the release version, still doesn't work from outside of VS. One other thing, the dll that uses these is a COM dll. Can you think of a reason this would change things?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 22:48:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069532#M119163</guid>
      <dc:creator>Steve_R_2</dc:creator>
      <dc:date>2016-01-11T22:48:36Z</dc:date>
    </item>
    <item>
      <title>Do you do a COMINITIALIZE and</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069533#M119164</link>
      <description>&lt;P&gt;Do you do a COMINITIALIZE and COMUNINITIALIZE in the DLL? (Or is it not your DLL?)&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2016 01:30:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069533#M119164</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2016-01-12T01:30:05Z</dc:date>
    </item>
    <item>
      <title>I call OleInitialize. Just to</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069534#M119165</link>
      <description>&lt;P&gt;I call&amp;nbsp;OleInitialize. Just to make things weirder, if I start the main program, that uses the com dll, to a different folder, things run ok. I checked what's loaded in each instance from process explorer. When I launch from the folder that fails, the process loads userenv.dll and ACGeneral.dll (windows compatibility dll). Otherwise everything that gets loaded is the same. When I check properties of the main program, there are no compatibility settings checked.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2016 20:38:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069534#M119165</guid>
      <dc:creator>Steve_R_2</dc:creator>
      <dc:date>2016-01-12T20:38:45Z</dc:date>
    </item>
    <item>
      <title>I might have found the</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069535#M119166</link>
      <description>&lt;P&gt;I might have found the problem. Somehow in&amp;nbsp;HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers an IgnoreFreeLibrary&amp;lt;my dll name&amp;gt; had been set for the program. Once I deleted the key, things seem to be working. I have to do more testing of various things, and I have no idea how the key got set, or how to prevent it getting re-set.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2016 20:56:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069535#M119166</guid>
      <dc:creator>Steve_R_2</dc:creator>
      <dc:date>2016-01-12T20:56:02Z</dc:date>
    </item>
    <item>
      <title>Interesting. Those flags are</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069536#M119167</link>
      <description>&lt;P&gt;Interesting. Those flags are usually set by the Application Compatibility Wizard that may appear after a program exits with an error. I once looked for more documentation on them but came up empty. What prompted you to look there?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2016 21:03:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069536#M119167</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2016-01-12T21:03:54Z</dc:date>
    </item>
    <item>
      <title>Since ACGeneral was loaded, I</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069537#M119168</link>
      <description>&lt;P&gt;Since ACGeneral was loaded, I thought something must be set that I didn't know about. So, I googled how to clear c&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;ompatibility&amp;nbsp;&lt;/SPAN&gt;info and people talked about this registry key. I looked and there is was. Things seem to be working ok now. But, I wish I knew how it got set in the first place.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2016 22:13:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/freelibrary-fails-to-unload-dll/m-p/1069537#M119168</guid>
      <dc:creator>Steve_R_2</dc:creator>
      <dc:date>2016-01-12T22:13:25Z</dc:date>
    </item>
  </channel>
</rss>

