Mexhost out of process crashed or destroyed outside of Matlab after 3 runs
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to run my mex function using the out of process matlab mexhost function. I am using the following wrapper to call my mex function.
function [t,y] = myfunction(x0,tspan)
persistent mh
if ~(isa(mh,'matlab.mex.MexHost') && isvalid(mh))
mh = mexhost;
end
[t,y] = feval(mh,"myfunctionMEX",x0,tspan);
end
I can use this wrapper 3 times before my function crashes and gives the error "Error executing C++ MEX function 'myfunctionMEX'. 'MATLABMexHost' with process ID '20172' crashed or was destroyed outside MATLAB." Can anyone help figure out why I can only run this a few times? I am trying to call it 4 times within the same script, but can only make it through 3 times without crashing. I am not calling clear or delete that would intentionally destroy the process.
0 Commenti
Risposte (1)
Swatantra Mahato
il 9 Lug 2021
Hi Kristen,
This issue might be caused by a known bug where the MEX function out-of-process execution runs out of memory when called too frequently. You can find the bug report here
One possible workaround is to reduce the frequency at which the MEX function is being invoked. The goal is to buy enough time for the MEX process to free up memory at a rate that is sustainable. This can be done by calling "pause" shortly before or after each invocation of the MEX function.
Note that the duration may need to be adjusted to suit each individual application.
Hope this helps
2 Commenti
Swatantra Mahato
il 12 Ago 2021
Can you share the functions you are using so I can reproduce the issue at my end?
Thanks
Vedere anche
Categorie
Scopri di più su Write C++ Functions Callable from MATLAB (MEX Files) in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!