Unfortunately I am not able to find a direct answer to this question
neither in documentation nor in newsgroups. I have an application
biggest part of which is dynamically reloaded in certain circumstances
- kind of webstart, but dynamic (you have to restart webstart to get a
new version of an application) and without a GUI.
The problem is that I have some singletons among my objects. Turns out
that garbage collector has some trouble with affected classes. When I
load new versions of my classes, the instances of the old versions are
not finalized. Accordingly their classloader stays in memory, and all
old classes do too. The classes are therefore never unloaded. The only
workaround I've found is to explcitly to to every class and set the
singleton instance inside it to null. Then the famed Java unloading
kicks in. I understand that class unloading is optional for JVMs and
depends on implementation (mine is HotSpot), but still - is that how
it's supposed to work? Is Singleton pattern flawed in these
circumstances (not that I insist that my usage of it is always
justified...)?