Re: Longevity of static class variables in Applet JVM
Richard Maher wrote:
Hi Mark,
"Mark Space" <markspace@sbc.global.net> wrote in message
news:z86Ml.32662$ZP4.26584@nlpi067.nbdc.sbc.com...
Richard Maher wrote:
Are static class variables once referenced in an Applet ever candidates
for
garbage-collection in a JVM, specifically when there are no longer any
active Applets currently referencing them? (That is, the page that
loaded
Yes, all objects, including static ones and classes, are available for
garbages collection once they are no longer referenced.
Really? So sometimes (pre-GC run) when I return to the page with the Applet,
I'll see things as they were when I was last there (eg: invocationCounter,
runningTotal) and other times they will be recreated afresh, even though
it's the same JVM? Doesn't sound very deterministic :-(
But it looks like this person disagrees with you: -
http://forums-beta.sun.com/thread.jspa?messageID=513241
Are you saying "the life of the program" referred to in that thread is the
life of the Applet rather than the life of the Classloader/JVM/Browser?
Maybe someone else with experience of such things can chime in?
I don't think that article conflicts with what Mark said. Objects
referenced by static class variables are going to be destroyed when the
JVM unloads.
How exactly a browser handles this, I have no idea.
I see.
If events are then delivered on such static objects (once again,
sometime
after the last Applet/ web-page to have referenced them has long gone)
what
thread is the event delivered in? (I'm guessing the standard browser EDT
but
the Java 6 reorg with Applet threads has me doubting it)
You have to be holding a refernce to a class to get events related to
it, so in that case it couldn't be garbage collected. Also, Swing and
AWT don't deliver any sort of GC events, ever. You're pretty confused.
Perhaps, there appears to be a lot of it about :-(
Not sure what the "GC events" you refer to are and I'm not really
interested, I was thinking more along the lines of something that implements
ActionListener.
But as colourful inflammatory accusations seem to be de rigueur at cljp
let's leave it at "You're talking bollocks!".
You might be able to get some info by keeping phantom references to
objects around. The queue associated with the phantom reference will
receive events when the object is gc'd.
It might be even easier however to just connect a debugger or profiler,
and observe which objects are gc'd and when.
Hmmm.
A lot of that depends on the JVM that is running and on the browser.
There are JVMs that never call stop() or unload when the browser moves off.
The real question though is why do you care? Is there something special
you are trying to accomplish?
--
Knute Johnson
email s/nospam/knute2009/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access