File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Garbage Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Garbage Collection" Watch "Garbage Collection" New topic

Garbage Collection

Thavaselvan S

Joined: Oct 30, 2006
Posts: 2
How does garbage collection happen in static variables
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

"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.


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.

JavaRanch Sheriff

[Asking smart questions] [About Bear] [Books by Bear]
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
I agree. Here's the link:
subject: Garbage Collection
It's not a secret anymore!