Click here to Skip to main content
15,664,619 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
Where memory for static variables will be allocated?
Posted

When a static variable is allocated, it will be stored as part of Methodtable.
Methodtable means When a class is loaded first time in application, separate memory will be allocated in appdomain for class level variables and methods inside class. .

If static variable is primitive type, it will be stored as part of Methodtable. If it is reference type, it will be stored inside the heap and the reference will be stored in Methodtable.
 
Share this answer
 
Comments
fjdiewornncalwe 7-Dec-12 10:22am    
Plagiarized from: Source

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900