Thread Subject: mexCallMatlab, error: JVM not running

Subject: mexCallMatlab, error: JVM not running

From: Antonio

Date: 2 Sep, 2010 22:07:21

Message: 1 of 3

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

Subject: mexCallMatlab, error: JVM not running

From: Walfredo

Date: 28 Mar, 2011 20:28:04

Message: 2 of 3

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>...
> 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

Subject: mexCallMatlab, error: JVM not running

From: Antonio

Date: 28 Mar, 2011 21:24:05

Message: 3 of 3

Nope, never managed to fix it. I just ended up running Matlab without the JVM in order to avoid the issue.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
mex jvm 2010b x... Walfredo 28 Mar, 2011 16:29:38
mex mexcallmatl... Antonio 2 Sep, 2010 18:09:05
rssFeed for this Thread

Contact us at files@mathworks.com