1 Memory Model of A Program, Methods Overview l Memory Model of JVM »Method Area »Heap »Stack.

Slides:



Advertisements
Similar presentations
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Advertisements

1 Procedural Programming Paradigm Stacks and Procedures.
Run-time Environment for a Program different logical parts of a program during execution stack – automatically allocated variables (local variables, subdivided.
Topic 10 Java Memory Management. 1-2 Memory Allocation in Java When a program is being executed, separate areas of memory are allocated for each class.
CSI 3120, Implementing subprograms, page 1 Implementing subprograms The environment in block-structured languages The structure of the activation stack.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
1 1 Lecture 14 Java Virtual Machine Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Memory Management & Method Calls in Java Program Execution © Allan C. Milne v
JAVA Processors and JIT Scheduling. Overview & Literature n Formulation of the problem n JAVA introduction n Description of Caffeine * Literature: “Java.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
1. 2 Introduction to Methods  Type of Variables  Static variables  Static & Instance Methods  The toString  equals methods  Memory Model  Parameter.
Runtime Environments Source language issues Storage organization
JVM-1 Java Virtual Machine Reading Assignment: Chapter 1: All Chapter 3: Sections.
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
Run-Time Storage Organization
1 Memory Model of A Program, Methods Overview l Closer Look at Methods l Memory Model of JVM »Method Area »Heap »Stack l Preview: Parameter Passing.
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Run-time Environment and Program Organization
1 Memory Model of A Program, Methods Overview l Memory storage areas for an executing program l Introduction to methods and methods definitions l General.
Unit 061 Java Virtual Machine (JVM) What is Java Virtual Machine? The Class Loader Subsystem Linking oVerification oPreparation oResolution Class Initialization.
1 Further OO Concepts II – Java Program at run-time Overview l Steps in Executing a Java Program. l Loading l Linking l Initialization l Creation of Objects.
1 Contents. 2 Run-Time Storage Organization 3 Static Allocation In many early languages, notably assembly and FORTRAN, all storage allocation is static.
Stacks and Frames Demystified CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Intro to Java The Java Virtual Machine. What is the JVM  a software emulation of a hypothetical computing machine that runs Java bytecodes (Java compiler.
Dale Roberts Procedural Programming using Java Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
13/02/2009CA&O Lecture 04 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
Runtime Environments Compiler Construction Chapter 7.
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
CSc 453 Runtime Environments Saumya Debray The University of Arizona Tucson.
ITEC 352 Lecture 18 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Exam –Average 76 Methods for functions in assembly.
Stack and Heap Memory Stack resident variables include:
CPSC 388 – Compiler Design and Construction Runtime Environments.
Lecture 8 February 29, Topics Questions about Exercise 4, due Thursday? Object Based Programming (Chapter 8) –Basic Principles –Methods –Fields.
MAL 3 - Procedures Lecture 13. MAL procedure call The use of procedures facilitates modular programming. Four steps to transfer to and return from a procedure:
Runtime Organization (Chapter 6) 1 Course Overview PART I: overview material 1Introduction 2Language processors (tombstone diagrams, bootstrapping) 3Architecture.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
Classes: user-defined types. Organizing method with a class A class is used to organize methods * Methods that compute Mathematical functions * The Scanner.
Processes and Virtual Memory
Chapter 4 Stacks and Queues © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
ITEC 352 Lecture 19 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Stacks Function activation / deactivation.
Programming Languages and Paradigms Activation Records in Java.
Thread basics. A computer process Every time a program is executed a process is created It is managed via a data structure that keeps all things memory.
Bank Account Example public class BankAccount { private double balance; public static int totalAccounts = 0; public BankAccount() { balance = 0; totalAccounts++;
RUNTIME ENVIRONMENT AND VARIABLE BINDINGS How to manage local variables.
Chapter 9 Life & Death of an Object Stacks & Heaps; Constructors Garbage Collector (gc)
Int main( ) { x = a(); } int a() { y = b(); } int b() { z = c(); } int c() { } 1.
(C) 2010 Pearson Education, Inc. All rights reserved.  Best way to develop and maintain a large program is to construct it from small, simple pieces,
RealTimeSystems Lab Jong-Koo, Lim
Variables Bryce Boe 2012/09/05 CS32, Summer 2012 B.
 Pearson Education, Inc. All rights reserved Methods: A Deeper Look.
Design issues for Object-Oriented Languages
Storage Classes There are three places in memory where data may be placed: In Data section declared with .data in assembly language in C - Static) On the.
Java Memory Management
Processes and threads.
Java Memory Management
ENERGY 211 / CME 211 Lecture 25 November 17, 2008.
Stack Memory 2 (also called Call Stack)
System Structure and Process Model
Understanding Program Address Space
Classes and Objects Part 2 Static Class Members and Arrays of Objects
Binding Times Binding is an association between two things Examples:
RECURSION Annie Calpe
UNIT V Run Time Environments.
When a function is called...
Dynamic Memory And Objects
Run-time environments
Return-to-libc Attacks
Implementing Functions: Overview
Presentation transcript:

1 Memory Model of A Program, Methods Overview l Memory Model of JVM »Method Area »Heap »Stack

2 Memory Model of JVM l So far we have learnt that to execute a java program, it is first compiled into bytecode, then invoke the JVM which loads and execute it. l However, to have a clearer understanding of how Java programs execute, we need to take a closer look at the memory model of JVM. l The JVM divides the memory into three main areas, as shown by the diagram below: Method Area Stack Heap

3 Memory Model of JVM (cont’d) l When a class file is loaded, the JVM extracts the following information and store them in the method area: »The bytecode for each method in the class »The class variables (static variables) »Class information – modifies, etc »Methods’ information – modifies, return type, etc The Heap l This is where objects are created. Memory is allocated for each of the instance variables of the object. l Also a reference to the method area containing the code for the methods of the object is stored with the data for the object. `

4 Memory Model of JVM (cont’d) Stack l At any particular point in the life-time of an application, only one method can execute. Such method is called current method. l A method may call another method, which may in turn call another, etc. l To keep track of the order from one method call to another, the stack memory area is used. l This is achieved by creating a stack frame for the current method in the stack. l The stack frame (also called activation record) contain the following information: l Local variables and parameters of the method l References to objects created by the method l Return address and return value of the method l If the current method calls another method, another frame is created for that method and push onto the stack – that method then becomes the current. l On exit from the current method, its frame is popped off the stack and discarded l Thus the value of local variables exists in memory only as long as the method executes.

5 Memory Model of JVM (cont’d) ‘