The moose likes Performance and the fly likes Do static variables consume memory?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Performance
Reply Bookmark "Do static variables consume memory??" Watch "Do static variables consume memory??" New topic
Author

Do static variables consume memory??

Ashish Mahajan
Ranch Hand

Joined: Feb 19, 2003
Posts: 77
Do static variables consume memory??
Since static blocks/variables are executed/loaded only at the first time the class is loaded, wiil they be loaded for the entire JVM lifetime or they will be accessed on the fly??
Thanx in advance.
Charles Rector
Greenhorn

Joined: Feb 18, 2003
Posts: 14
They are loaded on demand (when their containing class is used in some way), and then persist for the duration of the application.


Driven. You know. By people who drive.
 
 
subject: Do static variables consume memory??
 
Threads others viewed
static initializer block
Where do static variables live
When will a variable use memory from stack and when will use memory from heap?
about static variable
Do static variables, methods impose a penalty
Two Laptop Bag