Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mexCallMatlab, error: JVM not running

4 views
Skip to first unread message

Antonio

unread,
Sep 2, 2010, 6:07:21 PM9/2/10
to
Hello,
I have an instance of mexCallMATLAB() that *sometimes* throws an error with the message: "JVM not running", and I can't quite figure it out.

I'm writing a c++ mex file that uses the open-source portaudio library to access my soundcard. When the read buffer is full, it calls a callback function, which is where I want to use mexCallMATLAB to export the data so I can process it using m-files. For the moment, I set up a simple test where the callback function calls an m-file that does nothing more than increment a global counter:

----------------------------------------------------------------
mexaudio.cpp
----------------------------------------------------------------

static char errmsg[30];

static int audiocallback( const float *inputbuffer, float *outputbuffer){
mxArray *err=mexCallMATLABWithTrap(0,NULL,0,NULL,"mycounter");
if (err != NULL) {
mxArray *msg = mxGetProperty(err,0,"message");
mxGetString(msg,errmsg,30);
}
}

----------------------------------------------------------------
mycounter.m
----------------------------------------------------------------
function mycounter()
global mycount;
mycount=mycount+1;
end

If I run the program through the Matlab Desktop, I sometimes (1 in 3 chance) get the "JVM not running" error the first few times audiocallback is executed. After the first few errors, the program runs as expected. If I don't use WithTrap, then Matlab just crashes and closes without complaining. If I run the program through a console with the -nojvm option, I never get the error.

Is there a reason I'm not thinking of for why I'm getting the JVM error? Is there a work-around so I can continue to work with the matlab GUI?

In case it helps, I'm using MATLAB 7.10.0.499 (R2010a), 32-bit (glnx86) on a 32-bit linux operating system.

Cheers,
Antonio

Walfredo

unread,
Mar 28, 2011, 4:28:04 PM3/28/11
to
Hello Antonio,

Have you found what was going on? I am experiencing the same problem. I am using Matlab 2010b x64 in Windows XP Professional x64.

Regards,
Walfredo Fagundes

"Antonio" wrote in message <i5p76p$4bj$1...@fred.mathworks.com>...

Antonio

unread,
Mar 28, 2011, 5:24:05 PM3/28/11
to
Nope, never managed to fix it. I just ended up running Matlab without the JVM in order to avoid the issue.
0 new messages