Possible Duplicates:
Whats up with static memory in java?
What is the actual memory place for static variables?
In which memory static variables,local variables are presents like object is leave in heap
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you do a heap dump you get all the static values. The heap dump shows that static fields are in a special object for that class. You can access this “object” in the Sun/Oracle JVM by using the Unsafe class.
While local values are on the stack, eg. a reference, any object this references in on the heap. (Unlike languages like C++)
e.g.
The reference
hiin on the stack but the Object (which is most of the memory) is in the heap.