🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #3439

Re: runFinalizersOnExit() hangs my program when I exit()

#3439
From: Nikolaos Giannopoulos
Date: Wed, 14 Jan 1998 00:00
51 lines
2334 bytes
Andrew Bennett <abennett@borland.com> wrote in article
<34BBB748.94228598@borland.com>...
>
> Leo Breebaart wrote:
> 
> > Is this a JDK problem? A JCBL problem? A compilation problem?
> > Something stupid I'm overlooking (though I checked and this is
> > not in the FAQ)?
> >
> > Any help or suggestions for a workaround will be most appreciated.
> 
> Definitely not a JBCL problem.  I perceive it to be a JDK problem.
> Does this work in 1.1.5?
> 
> Another approach might be to derefence all your objects, and call
> java.lang.Runtime's runFinalization().

Andrew,

Just came accross this interesting item in the "RMI and Object
Serialization" FAQ at http://java.sun.com:81/products/jdk/rmi/faq.html that
re-inforces your response.

I'm assuming that Leo's problem did not involve RMI or object
serialization, but I think that is quite relevant regardless.

 "  Executing System.runFinalizersOnExit in the client before termination
is not sufficient,
    because not all of the necessary processing is handled in a finalizer;
i.e. the
    "unreferenced" message will not get sent to the server. (Using
"runFinalizersOnExit" is
    generally ill-advised and deadlock-prone anyway.)"

    If you need to use System.exit() to terminate a client VM, to ensure
that remote
    references held in that VM are cleaned up in a more timely fashion, you
should make
    sure that there are no remote references still reachable (explicitly
null any local
    references to them unreachable from running threads), and then it helps
to do something
    like this before exiting: 

            System.gc();
            System.runFinalization();
-- 
Nikolaos Giannopoulos
Solmar Solutions Inc.
nikolaos@solmar.ca
Technical Details
Message-ID: <01bd20d1$3dec6c40$0164cdcd@solmar>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <34BB79E8.C105066A@lspace.org> <34BBB748.94228598@borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5619,23d0b465eda3bbde
X-Google-Attributes: gidf5619,public
X-Google-Thread: 1089d0,23d0b465eda3bbde
X-Google-Attributes: gid1089d0,public
From: "Nikolaos Giannopoulos" <nikolaos@solaris.ca>
Subject: Re: runFinalizersOnExit() hangs my program when I exit()
Date: 1998/01/14
Message-ID: <01bd20d1$3dec6c40$0164cdcd@solmar>
X-Deja-AN: 315782626
References: <34BB79E8.C105066A@lspace.org> <34BBB748.94228598@borland.com>
Organization: None
Newsgroups: borland.public.jbuilder.java.api,borland.public.jbuilder.jbcl