Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can anybody explain memory allocation for static contents?

 
Bhargavan Marepalli
Greenhorn
Posts: 15
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody explain memory allocation for static contents?
for example i hav 5 classes and i hav static variable and static methods in all classes..
so memory to those all static wiil be stored at same location and only once..all objects use that memory
My satement is crrect or not??
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you care where that is stored? The only thing you need to know is that static variables are shared by all the instances.
 
James E Baker
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you're looking for. It will be stored in whatever memory location is available. Just like any variable, you can't predict the specific address of the memory block it will be stored in. The location isn't relative to anything else in your code.

Really, once that class is a part of your program, any memory it allocates is just overhead. It's nothing you need to manage.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic