Mexhost out of process crashed or destroyed outside of Matlab after 3 runs

6 ビュー (過去 30 日間)
Kristen Bruchko
Kristen Bruchko 2021 年 7 月 6 日
コメント済み: Swatantra Mahato 2021 年 8 月 12 日
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.

回答 (1 件)

Swatantra Mahato
Swatantra Mahato 2021 年 7 月 9 日
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 件のコメント
Kristen Bruchko
Kristen Bruchko 2021 年 8 月 10 日
編集済み: Kristen Bruchko 2021 年 8 月 10 日
Unfortunately, the pause function does not seem to help, even if called for a few minutes between each mex function call. I also still see the problem if I am not using the out-of-process function.
Swatantra Mahato
Swatantra Mahato 2021 年 8 月 12 日
Can you share the functions you are using so I can reproduce the issue at my end?
Thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWrite C++ Functions Callable from MATLAB (MEX Files) についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by