# “MATLink has lost connection to the MATLAB engine”

I started using MATLink and find it extremely useful (Windows 7, MATLAB R2016a). I now run Simulink models from Mathematica. I use Mathematica's Table to vary parameters and run simulations hundred of times.

The issue I have is that under heavy use, I frequently (not always) get this error:

MATLink has lost connection to the MATLAB engine; please restart MATLink to create a new connection. If this was a crash, then please try to reproduce it and open a new issue, making sure to provide all the details necessary to reproduce it.

After this, MATLAB still runs, but a process named mengine(255t9_shm) is unresponsive.

So my questions are:

1. Is there a log or any way to help debug this?
2. If this is a known issue, are there any recommendation to help reduce the probability of happening?

Description:
A problem caused this program to stop interacting with Windows.

Problem signature:
Problem Event Name:   AppHangB1
Application Name: mengine.exe
Application Version:  0.0.0.0
Application Timestamp:    53ed4362
Hang Signature:   d307
Hang Type:    0
OS Version:   6.1.7601.2.1.0.256.48
Locale ID:    1033


UPDATE: When connecting directly to MATLAB using enableservice('AutomationServer', true), and after couple hundred simulations MATLAB crashed:

Problem signature:
Problem Event Name:   APPCRASH
Application Name: MATLAB.exe
Application Version:  9.0.0.0
Application Timestamp:    5681c359
Fault Module Name:    nvoglv64.DLL
Fault Module Version: 9.18.13.2063
Fault Module Timestamp:   51dd4126
Exception Code:   c0000005
Exception Offset: 00000000009e7448
OS Version:   6.1.7601.2.1.0.256.48
Locale ID:    1033

• This is not a known issue. There is a log in \$UserBaseDirectory/ApplicationData/MATLink, but it is unlikely to be helpful in this case. Can you at least show the basic calling syntax you are using, so we can have some idea about what data structures are being transferred? You could also try this method to be able to keep interacting with MATLAB directly, and check what it is doing: mathematica.stackexchange.com/a/69937/12 – Szabolcs Apr 28 '17 at 13:12
• OK, so it seems mengine hangs (?). The problem is that the only way we can fix this is if we can reproduce the problem. – Szabolcs Apr 28 '17 at 14:57