Possible Duplicate:
Are static fields open for garbage collection?
If an object has a static reference in some class, will that object never be garbage collected? Also at what point will a static field be initialized?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, this has been asked on SO multiple times. Since these are two questions, let’s break it down:
Static variables are garbage collected when the ClassLoader through which they are loaded is electable for garbage collection. Check this post:
Are static fields open for garbage collection?
As for initialization, they are initialized once the class holding them is first loaded. Check this post also:
Why static fields are not initialized in time?