Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Contents of Stack Frame in Java

It is evident from Java Virtual Machine Implementation (http://docs.oracle.com/javase/specs/jvms/se7/html/index.html) that stack frame present on heap which stores the method's runtime data. But what are the contents of stack frame in java and how the stack frame is organized to store values of local variables and intermediate results. How is the data structure organized.

like image 953
Ankit Zalani Avatar asked Dec 07 '13 12:12

Ankit Zalani


People also ask

What are the contents of stack frame?

A stack frame consists of many bytes, each of which has its own address; each kind of computer has a convention for choosing one byte whose address serves as the address of the frame. Usually this address is kept in a register called the frame pointer register while execution is going on in that frame.

What is the purpose of a stack frame?

A stack frame is a memory management technique used in some programming languages for generating and eliminating temporary variables. In other words, it can be considered the collection of all information on the stack pertaining to a subprogram call. Stack frames are only existent during the runtime process.

What is a stack frame and what does it hold?

Stack is one of the segments of application memory that is used to store the local variables, function calls of the function. Whenever there is a function call in our program the memory to the local variables and other function calls or subroutines get stored in the stack frame.

What is frame data in Java?

A frame is used to store data and partial results, as well as to perform dynamic linking, return values for methods, and dispatch exceptions. A new frame is created each time a method is invoked.


1 Answers

First of all, stack frame is part of JVM stack, not Heap [JVM memory is divided in 5 parts: Method Area, Heap, Stack, PC Register and Native Memory.]

To answer your question, stack frame is divided into three parts: local variable array, frame data and operand stack. Refer to the following link for detailed info: http://www.artima.com/insidejvm/ed2/jvm8.html

like image 129
Tukai Ghosh Avatar answered Sep 30 '22 11:09

Tukai Ghosh