DestroyJavaVM() never returns

Discussion in 'Java' started by MikL, Feb 15, 2005.

  1. MikL

    MikL Guest

    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");
     
    MikL, Feb 15, 2005
    #1
    1. Advertising

  2. On Tue, 15 Feb 2005 15:12:43 +1100, MikL wrote:
    > 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

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
     
    Gordon Beaton, Feb 15, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amit
    Replies:
    0
    Views:
    1,016
  2. zorba
    Replies:
    2
    Views:
    2,425
    zorba
    Mar 22, 2005
  3. Soren Kuula
    Replies:
    1
    Views:
    473
    Henry S. Thompson
    Dec 1, 2005
  4. Replies:
    1
    Views:
    5,654
    John B. Matthews
    May 1, 2009
  5. Olivier GROSSET-GRANGE

    JNI, threads are still running after DestroyJavaVM()

    Olivier GROSSET-GRANGE, Feb 19, 2013, in forum: Java
    Replies:
    2
    Views:
    1,016
Loading...

Share This Page