This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Static variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static variable" Watch "Static variable" New topic
Author

Static variable

Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
Dear all,
When are static variables eligible to garbage collection?
thanks
daniel
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Static variables are garbage collected when the class they belong to is garbage collected. Classes can only be collected when nothing refers to that class anymore.
kind regards
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
If the static variable is being used by a number of objects then it is eligible for GC when the last object using it is GC'd.


The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Static variable
 
It's not a secret anymore!