Mex-file works only in Matlab COMMAND Window

1 view (last 30 days)
ben
ben on 11 Jun 2013
Hi, I thought my mex-code was wrong because it didn't work for some inputs.
But i've just tried to run it from the Matlab Command Window, and it works !
How can this be possible ? Why it works in Command Window, and not in the Matlab Desktop ?
In Matlab Desktop, it doesn't really crash, it just hangs, never stops, I have to kill Matlab to stop it. I thought it was an infinite loop in the mex-code, but it works in command window.
Thanks.
  4 Comments
Jonathan Sullivan
Jonathan Sullivan on 11 Jun 2013
Sounds like there may be a bug in your mex file. Most likely a memory management issue.
ben
ben on 11 Jun 2013
yes maybe, but then, it would be memory issue related to the use of Java Virtual Machine ? I don't get why it works when Java is not used.

Sign in to comment.

Answers (3)

Jan
Jan on 11 Jun 2013
If the MEX confuses the memory manager, the results are random. So your observed relation between starting Matlab without Java and the successful run of your program can be an illusion. Even trying it 1000 times will not prove, that the MEX works correctly then.

ben
ben on 11 Jun 2013
I really tried to debug the mex code, but my conclusion is that it doesn't hang because of a bad loop or something.
The code works in C++, and I ran the two codes (just C++ and in a mexFunction), and it seems the mex-code just stop some steps before the end, and Matlab begin to hang.
  1 Comment
James Tursa
James Tursa on 11 Jun 2013
I'm in agreement with Jan ... sounds like a bug in your code.

Sign in to comment.


ben
ben on 12 Jun 2013
When you run Matlab (with java), does the computation use the memory of the Java Virtual Machine ?
  1 Comment
ben
ben on 12 Jun 2013
Edited: ben on 12 Jun 2013
It doesn't make sense, the C++ run of the same code run fast and seems to use just a bit of memory. But when java is enabled in Matlab, the memory use seems big.
If I increase the Java heap limit, the memory use increases too (still hanging).
I don't get where (in which kind of situations) Java could use or leak more memory than a simple C++ run.

Sign in to comment.

Categories

Find more on Startup and Shutdown 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!