Hi All,
My approach is Data class is singleton which will hold one instance of DBManager class (which performs low level I/O operations and memory caching - associated to one db file only)
Bear "reusability" in mind that I've created DBManager is public class. So my design will access Data class to perform all kind of I/O operations.
I would call Data class by Data.getData() - same approach of Runtime.getRuntime() class.
What's itching my mind is I'm not holding the reference of singleton Data object and Data class is holding its created instance by itself.
I've read somewhere in the net that, if VM reload the singleton class, everything will be (re)initialized (mean all static fields). Pretty straight forward one.
If there's no reference to the object then it'll be GC'ed. Here Data class holds the reference to it (no
thread knows whether Data class has been unloaded and reloaded or not).
Let me come to my question: Very first time one client calls Data.getData() - Class is loaded and Singleton object is created and Class member is holding the reference to it. Then after this request, assume nearly a week/two, there's no request arrived to server to call again Data.getData(). In this case, will this class be unloaded by JVM? What will happen, after above said assumed long period when a new client make a request to the server to process some request?
Or simply tell me under what conditions, one class will be unloaded by JVM?
I'm not using any study guide or anything. So I couldn't confirm myself.
[I ran around 100 threads in different time like after 1 min, 10 mins, 1 hr to check whether JVM is using some time out to unload a class (and no thread is holding the reference variable to Data - use and throw mechanism just calling Data.getData()) and found same object is being referenced. ]
Please clarify me
Thanks in advance,
Seetha...