This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Static Var GC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static Var GC" Watch "Static Var GC" New topic
Author

Static Var GC

Seth Anshul
Greenhorn

Joined: May 02, 2006
Posts: 16
Can static variables be garbage collected in Java?
Amit Y Desai
Ranch Hand

Joined: Dec 06, 2007
Posts: 35
if a static variable is set to null,then memory it references get garbage collected.

Useful note : Variables with the longest lifetime are static variables, you should be careful to assign null to any variable that are no longer used, especially if they reference large data structures.
Seth Anshul
Greenhorn

Joined: May 02, 2006
Posts: 16
Thanks Amit..
 
Don't get me started about those stupid light bulbs.
 
subject: Static Var GC
 
Similar Threads
static and non static methods
property file dynamic vs static
Single tone Vs Static
WA #1.....word association
static and non static methods