Mexhost out of process crashed or destroyed outside of Matlab after 3 runs
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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
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 Exchange에서 Write 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!