[kepler-dev] fix for ptolemy matlab actor
Christopher Brooks
cxh at eecs.berkeley.edu
Wed Jan 16 11:46:08 PST 2008
Hi Ian,
Thanks, the change looks good, I folded it into the tree.
We should be doing a beta release at the end of this month, so your
change is very timely.
Matlab failing after the second run has been a long standing issue.
_Christopher
--------
I've just started using the ptolemy matlab expression actor
(ptolemy.matlab.Expression) and I was finding the problem that
multiple runs would cause a crash.
You could always run a model once but if you invoked it a second
time without restarting ptolemy (i.e. press run, stop, run, stop)
it would crash when stopping the second run.
I tracked down the issue to ptmatlab.cc in the routine
Java_ptolemy_matlab_Engine_ptmatlabEngClose. It was deleting the
output buffer before closing the matlab engine and without letting
the matlab engine know not to use it. A solution would be to
either call engOutputBuffer(ep, NULL, 0) before destroying the
memory, or to simply delay destroying the memory until after the
matlab engine instance is closed. I chose the latter and now I can
run it fine without any crashes.
I have attached my version of ptmatlab.cc. It has this change plus
a few fflush(stdout) statements after the logging printfs. This is
important as without them the java and the C log will use
different buffers and you cannot verify the correct calling order.
Ian
More information about the Kepler-dev
mailing list