aspose file tools
The moose likes Java in General and the fly likes Memory allocations in java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Memory allocations in java" Watch "Memory allocations in java" New topic
Author

Memory allocations in java

Archies Gomes
Ranch Hand

Joined: Jun 19, 2005
Posts: 34
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

Joined: Jan 03, 2006
Posts: 490
Objects are stored on the heap.

When methods are called they are moved to the stack for processing.


"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12271
    
    1
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 ]

Java Resources at www.wbrogden.com
Robert Hill
Ranch Hand

Joined: Feb 24, 2006
Posts: 94
If methods didn't go on the stack, recursion would be impossible.
Pratibha Malhotra
Ranch Hand

Joined: Dec 21, 2003
Posts: 199
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,


~ Pratibha Malhotra<br /> <br />Sun Certified Java Programmer<br />SCEA 1.4 (In Progress)<br />~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />"Many of life's failures are people who did not realize how close they were to success when they gave up!!"
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12271
    
    1
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Memory allocations in java
 
Similar Threads
Java - Works, but doesnt work...
using public class in other packages
Array Question
MySQLException
Making a quadtree from a Matrix using recursion