aspose file tools*
The moose likes Beginning Java and the fly likes static variable memory allocation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "static variable memory allocation" Watch "static variable memory allocation" New topic
Author

static variable memory allocation

vijaya bharath
Ranch Hand

Joined: Jun 10, 2005
Posts: 66
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?


Regards,<br />Vijaya Bharath.<br />SCJP1.4 <br />SCWCD5.0
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
vijaya bharath
Ranch Hand

Joined: Jun 10, 2005
Posts: 66
Thanks for your reply
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static variable memory allocation
 
Similar Threads
asking about static n non static memory difference
Serializable statics
the variable in static method
class question
about static variable