Azzera filtri
Azzera filtri

unloadlibrary still keeps the library loaded!

14 visualizzazioni (ultimi 30 giorni)
Marc
Marc il 23 Dic 2013
Risposto: Philip Borghesani il 19 Nov 2015
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?

Risposte (2)

Marc
Marc il 23 Dic 2013
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 Commento
Jørgen
Jørgen il 19 Nov 2015
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.

Accedi per commentare.


Philip Borghesani
Philip Borghesani il 19 Nov 2015
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.

Categorie

Scopri di più su Manage Products in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by