File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes static variables - kept on Heap or Stack Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "static variables - kept on Heap or Stack" Watch "static variables - kept on Heap or Stack" New topic
Author

static variables - kept on Heap or Stack

jim gemlo
Greenhorn

Joined: Feb 24, 2004
Posts: 20
Ok Instance variables are kept with their objects on the Heap but what about static instance variables? Where are they kept? Since there is one variable per class regardless of how many objects are created, are they stored outside of the object on the heap or are they put on the stack?
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
See this post with a very erudite answer from Ernest.

The short answer is, it depends. It's not the stack. It may be the heap, but technically it can't be. It's in some memory that the JVM has access to that isn't the heap. That's what I understood. Oh, and it doesn't matter.

Jules
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static variables - kept on Heap or Stack
 
Similar Threads
Object life cycle
Garbage Collection of static variables
Heap and Stack difference.
implementation for static and non-static methods stored in memory
Where is the Methods place in Memory ?