• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage Collection

 
Thavaselvan S
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does garbage collection happen in static variables
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Thavaselvan S",

Two things. First...

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Second...

Please take the time to choose the correct forum for your posts. This forum is for JSP questions. I've moved you post to a more appropriate forum.

Thanks!
bear
JavaRanch Sheriff
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most objects referred-to by static variables will never be garbage collected. To be garbage collected, the class containing the static variable needs to get unloaded. That will only happen when its class loader gets garbage collected.

If the class was loaded by the system class loader (i.e. off the classpath), it will never be garbage collected, because the system class loader is never garbage collected.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic