MATLAB Answers

Killing a (mex) Function When It Doesn't Respond to Ctrl-C or Ctrl-Break Under WIN64

16 views (last 30 days)
Mark Stone
Mark Stone on 1 Jun 2015
Commented: Pavel Holoborodko on 23 Jan 2020
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.

More Answers (2)

Peter Lawrence
Peter Lawrence on 6 Oct 2017
Edited: Walter Roberson on 6 Oct 2017
Yes, it's part of the "undocumented" matlab stuff, but at least it works, and works well.
  1 Comment
Mark Stone
Mark Stone on 6 Oct 2017
Nice. This addresses coding of a mex file so that it can be interrupted. However, it does not address the interruptibility of a mex file provided without source code. So if I understand correctly, I would still be out of luck if trying to run a mex file which was not designed to be interrupted and for which I don't have access to source code.

Sign in to comment.

Victor on 16 Jun 2016

Who accepted that unacceptable answer!?

No but seriously this is sooooooooooooooooooooooooooooooooooooooooo annoying!

Pavel Holoborodko
Pavel Holoborodko on 23 Jan 2020
@"Plus, it is not clear to me what would happen in that 2nd link if the MATLAB Memory Manager was interrupted in the middle of something when its Worker Thread got terminated."
Suggestions to the situation are provided in the post. In short, WorkerThread must be used for computations, not for memory allocations (especially not by MATLAB Memory Manager functions). It is really bad idea to mix allocations & computations in (any) numerical code anyway.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!