I have a Mex-function, say myfunction.mexmaci64
(which is the correct ending on OS X).
Now, myfunction is linked against a library mylibrary.dylib
. Both, mex-file and library, reside in the same folder.
Now, whenever I change something in mylibrary
, MATLAB does not reload the new library version but instead uses the old one until I do restart MATLAB. That is very anoing when doing development and debugging work.
Is there a way to force MATLAB to reload the library without restarting the application?
Note: It would be easy to link the library statically into the mex function. However, as I link the same library across quite a few mex-files, I would prefer to keep my single shared library to reduce compilation times and data redundancy.
Concerning the discussion wether the clear mex
helps:
[~, loaded_mexes] = inmem('-completenames'); % get canonica
returns a list with all loaded mex-files. This list does not contain the linked library, but only the mex-files itself. Using clear mex
successfully empties this list, but does not unload mylibrary
- running the mex function again still yields the same output as it did with the old shared library.
To clear a library from memory I usually have excellent luck with
bdclose all;
Then if I'm really feeling militant, I'll do:
bdclose all; % clear all libraries out of memory ( supposedly )
clear all; % clear all workspace variables, mex, etc. ( supposedly )
rehash; % cause all .m files to be reparsed when invoked again
Does clear mex
do what you need?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With