Quantcast
Channel: VBForums - API
Viewing all articles
Browse latest Browse all 168

Problem with FreeLibrary in VB6 IDE

$
0
0
FreeLibrary doesn't free a loaded DLL in VB6.

If I load a DLL file with LoadLibrary, get a function pointer with GetProcAddress, and then call the function with DispCallFunc, it runs that function. If I then remove the DLL from memory using FreeLibrary, and then again try to call that same function using DispCallFunc, it should at least fail to work, and at most crash completely. However, I found out shockingly that the function runs just fine! This indicates that the DLL was NOT unloaded from memory, and that the memory that the DLL occupied was NOT freed/deallocated (which wastes memory space, keeping a DLL in memory that no longer needs to be in memory). And it doesn't matter how many times I call FreeLibrary. I can call it from a command button, and click that button 100 times, but it NEVER frees the DLL from memory. It's like the DLL file is STUCK in memory.

When I save an EXE file of the same program that I'd been working on in VB6, and then run it, and do the same tests on the DLL file from within the EXE file (rather than from within VB6) the FreeLibrary command works as expected, removing the DLL file from memory. Only in the VB6 IDE itself does FreeLibrary fail to remove the DLL file from memory.

Viewing all articles
Browse latest Browse all 168

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>