• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static variable memory allocation

 
vijaya bharath
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a doubt. Memory for static variable will be allotted at compile time. What if i write a class with 50000 static variables and compile that and never use that class. What about the memory allotted.Is it waste of memory?
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The memory will be allotted when the class is *loaded* at runtime. A class that doesn't get used doesn't get loaded, so no, it wouldn't have any effect on memory consumption.
 
vijaya bharath
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic