I am in the process of developing an SFunction and compiled submodel in Simulink, an SFunction that calls into a DLL compiled using Realtime Workshop. The problem is, once I compile the submodel once, execute it in native Simulink through the SFunction and the model finishes, MATLAB still keeps a handle to the submodel DLL. I cannot recompile the DLL until MATLAB is restarted, forcing the release of the DLL.
I have even gone so far as to see if ProcessExplorer could force closed the handle but it can't.
How do you bind the S-Function to the DLL? If you bind at link time then you could try to bind at runtime and explicitly release the handle in mdlTerminate
. That way, MATLAB should never even know that you accessed the DLL. Of course this makes the actual interaction with the DLL from within the S-Function somewhat messier.
I think it would work if you just rename the actual DLL
to something else and then recompile. I know it works for mex
files. If this doesn't work, you can try this solution.
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