MATLAB crashes while re-running compiled mex file.
Show older comments
I have a cpp file which gets compiled successfully in Matlab and gives right results. But if I recall the function again, then Matlab crashes. There is no issue if I recompile it again and then run. I assume it is due to some error as mentioned in this post . Why does it work if I recompile it each time and does not work (Matlab crashes) in case of recalling the function in a loop? - How to get hold of the error?
3 Comments
Image Analyst
on 28 May 2016
What does "I recall the function" mean? How are you calling it? What changes did your program make so that the second time the max file is called it can't work? Perhaps a needed data file got deleted??? Who knows?
Michael Mathew
on 28 May 2016
Edited: Walter Roberson
on 31 May 2016
James Tursa
on 31 May 2016
This is usually the result of a memory access violation caused by a coding error, but we would need to see your code. The reason it may work the first time but not subsequent times is that the first time corrupts memory but doesn't access the corrupted memory until the second time. Recompiling may clear out the corrupted memory before it gets accessed.
Answers (0)
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!