MATLAB: Killing a (mex) Function When It Doesn’t Respond to Ctrl-C or Ctrl-Break Under WIN64
ctrl-c; kill-job
Is there a way to kill a (mex) function running in MATLAB and which doesn't respond to Ctrl-C or CTrl-Break, other than by killing the whole MATLAB process (session)? To be concrete, assume R2014A WIN 64.
Two things happen when MATLAB returns back to the command line:
Memory leaked by any mex files is cleaned up (mxMalloc... or MATLAB arrays). The best practice is to only rely on automatic clean up in the event of an error.
Any pending display/graphics messages are processed by MATLAB. This can be forced by adding a drawnow to your code. In general this should not cause an issue because there should not be a huge number of events pending but there have been bugs in the distant past.
Best Answer