unloadlibrary still keeps the library loaded!

14 次查看(过去 30 天)
Hello,
I have a socket communication framework wrapped inside of a library (dll). I can use it by using loadlibrary. That works fine. My problem is that calling unloadlibrary doesn't generate any error (the first time it is called), but then it appears that the library is still in memory: if I try to delete the shared library file (the dll file), Windows complains saying that some other application is using it. Only after quiting Matlab will I be able to successfully delete the library file. That makes me think: unloadlibrary is not doing its job, since Matlab is still keeping it in memory.
Am I missing something?

回答(2 个)

Marc
Marc 2013-12-23
A little precision:
it seems that on specific Matlab version, or OSs (or a combination of both), unloadlibrary works fine. But in my case (Windows 8.1, Matlab R2012b), the library stays in memory (also verified with "Process explorer"
  1 个评论
Jørgen
Jørgen 2015-11-19
I have encountered the exact same problem with Matlab 2015A on Windows 8.1. The problem does not exist in Windows 7.
I recently filed a service request on this issue, which I hoped is answered soon.

请先登录,再进行评论。


Philip Borghesani
Philip Borghesani 2015-11-19
The problem most is most likely with your library not with MATLAB. When a library is loaded the operating system increases the load count for the library by one and unloadlibrary decrements it by one. If the count goes to 0 the operating system has the option of unloading it. Doing so is not mandatory... Any other library loading the library you are using or the library itself may be locking itself into memory by calling loadlibrary on itself.
Many libraries do not work correctly if unloaded and reloaded. Calling unloadlibrary should be considered optional.
With windows com dlls the unload is deliberately delayed to prevent thrashing when the dll is unloaded and reloaded in rapid succession.

类别

Help CenterFile Exchange 中查找有关 Manage Products 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by