• Post Reply Bookmark Topic Watch Topic
  • New Topic

Memory allocations in java  RSS feed

 
Archies Gomes
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Can anyone please give me a good link for a topic on memory allcoations in java as to,
*)where are all the static objects of a class stored
*)where are the methods stored during exection,I mean which part of memory.
*)are members of a Ojects or instance methods and class methods or static methods stored on the same memory location during their execution?
*)where are primitive types stored which are delcared as attribute of the class.

So for Ex,

where is the temp1,temp2,temp3 stored
where is int a stored
where is int b stored
where is int c stored
and whre are both of the methods of the above class stored while execution

Thanks All,Appreciate your valuable Time.
[ September 18, 2006: Message edited by: Archies Gomes ]
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Objects are stored on the heap.

When methods are called they are moved to the stack for processing.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When methods are called they are moved to the stack for processing.

Only references to objects appear on the stack.

Here you can download extensive documentation on how the JVM works.
Bill
[ September 18, 2006: Message edited by: William Brogden ]
 
Robert Hill
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If methods didn't go on the stack, recursion would be impossible.
 
Pratibha Malhotra
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instance variables and Objects are stored in HEAP AREA and become a candidate for garbage collection after going out of scope.

Local var(whether static or not), methods reside on stack and are never Garbage collected. Its just that stack is reused once method execution is completed.


HTH,
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say
When methods are called they are moved to the stack for processing.

what do you think that means?? It sounded to me like an implication that method byte code is moved when a call is executed.
Bill
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!