DestroyJavaVM() never returns

M

MikL

Hi all,

I've written a Windows EXE to launch the JVM, which it does very nicely. It
runs an application that uses Hypersonic and Spin. However when the
application exits via System.exit(), I've found resources (eg. JARs and the
EXE) are remaining locked, and memory is remaining allocated even though the
application disappears. According to the launcher's log file, the launcher
program itself appears to be hanging on the call to DestroyJavaVM.

Any suggestions?

The snippet of code where it's occurring:

log("running..");
(*vEnv)->CallStaticVoidMethod(vEnv,vMainClass,vMain,vMainArgs);
if ((*vEnv)->ExceptionOccurred(vEnv))
(*vEnv)->ExceptionDescribe(vEnv);

// I've tried it with and without the following 3 lines of code.
if ((*vVm)->DetachCurrentThread(vVm) != 0)
Raise(&ELauncher,"Could not detach main thread");
log("detached main thread");

if (vVm != NULL)
{
log("destroying JVM"); // <---- this message is logged
(*vVm)->DestroyJavaVM(vVm);
log("JVM destroyed"); // <---- this message is NOT logged.
}
else
log("no JVM to destroy");
 
G

Gordon Beaton

I've written a Windows EXE to launch the JVM, which it does very
nicely. It runs an application that uses Hypersonic and Spin.
However when the application exits via System.exit(), I've found
resources (eg. JARs and the EXE) are remaining locked, and memory is
remaining allocated even though the application disappears.
According to the launcher's log file, the launcher program itself
appears to be hanging on the call to DestroyJavaVM.

Any suggestions?

Yes - don't detach the main thread. Just invoke the main method and
*exit* from the launcher when it returns.

If you search archives of this group, I think you'll find that
DestroyJavaVM() has never worked properly for anyone. Its
documentation claims "The JVM still does not support unloading".

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top