Memory organization and usage A computer’s memory is, at its lowest level, composed of binary digits (bits). The memory is organized into bytes, which.

Slides:



Advertisements
Similar presentations
Chapter 21 Implementing lists: array implementation.
Advertisements

Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 11 Memory Management C makes it easy to shoot.
Dynamic Memory Allocation in C.  What is Memory What is Memory  Memory Allocation in C Memory Allocation in C  Difference b\w static memory allocation.
Names and Bindings.
CERTIFICATION OBJECTIVES Use Class Members Develop Wrapper Code & Autoboxing Code Determine the Effects of Passing Variables into Methods Recognize when.
Dynamic memory allocation. The process of allocating memory at run time is known as dynamic memory allocation. C have four library functions for allocating.
Arrays.
1 Day 03 Introduction to C. 2 Memory layout and addresses r s int x = 5, y = 10; float f = 12.5, g = 9.8; char c = ‘r’, d = ‘s’;
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Day 20 Memory Management. Assumptions A process need not be stored as one contiguous block. The entire process must reside in main memory.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Arrays. Memory organization Table at right shows 16 bytes, each consisting of 8 bits Each byte has an address, shown in the column to the left
Dynamic Memory Allocation in C++. Memory Segments in C++ Memory is divided in certain segments – Code Segment Stores application code – Data Segment Holds.
Chapter 10 Storage management
Memory Management Memory Areas and their use Memory Manager Tasks:
Pointer. Warning! Dangerous Curves C (and C++) have just about the most powerful, flexible and dangerous pointers in the world. –Most other languages.
Overview Memory definitions Random Access Memory (RAM)
Pointers and Dynamic Variables. Objectives on completion of this topic, students should be able to: Correctly allocate data dynamically * Use the new.
1 ES 314 Advanced Programming Lec 3 Sept 8 Goals: complete discussion of pointers discuss 1-d array examples Selection sorting Insertion sorting 2-d arrays.
Elementary Data Types Scalar Data Types Numerical Data Types Other
MEMORY MANAGEMENT By KUNAL KADAKIA RISHIT SHAH. Memory Memory is a large array of words or bytes, each with its own address. It is a repository of quickly.
1 CSCE 1030 Computer Science 1 Arrays Chapter 7 in Small Java.
CSE 116 Introduction to Computer Science For Majors II Carl Alphonce 219 Bell Hall.
Memory organization and usage A computer’s memory is, at its lowest level, composed of binary digits (bits). The memory is organized into bytes, which.
Overview Working directly with memory locations is beneficial. In C, pointers allow you to: change values passed as arguments to functions work directly.
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 10. Pointers & Dynamic Data Structures.
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
C programming or Fun with pointers Tutorial #2 CPSC 261.
Introduction to Arrays in Java Corresponds with Chapter 6 of textbook.
The basics of the array data structure. Storing information Computer programs (and humans) cannot operate without information. Example: The array data.
ARRAYS 1 Week 2. Data Structures  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently 
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
Review of ICS 102. Lecture Objectives To review the major topics covered in ICS 102 course Refresh the memory and get ready for the new adventure of ICS.
Computer Programming 12 Mr. Jean April 24, The plan: Video clip of the day Upcoming Quiz Sample arrays Using arrays More about arrays.
Chapter 4 Memory Management Virtual Memory.
SPL – Practical Session 2 Topics: – C++ Memory Management – Pointers.
Pointers in C++. 7a-2 Pointers "pointer" is a basic type like int or double value of a pointer variable contains the location, or address in memory, of.
Polymorphism Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 7.3.
Week # 2: Arrays.  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently  Types of data.
Lecture by: Prof. Pooja Vaishnav.  Language Processor implementations are highly influenced by the kind of storage structure used for program variables.
+ Dynamic memory allocation. + Introduction We often face situations in programming where the data is dynamics in nature. Consider a list of customers.
Memory Management in Java Computer Science 3 Gerb Objective: Understand references to composite types in Java.
Programming Languages and Paradigms Activation Records in Java.
Data Structures - Part I CS 215 Lecture 7. Motivation  Real programs use abstractions like lists, trees, stacks, and queues.  The data associated with.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 8 – Memory Basics Logic and Computer Design.
1 KU College of Engineering Elec 204: Digital Systems Design Lecture 22 Memory Definitions Memory ─ A collection of storage cells together with the necessary.
Arrays in MIPS Assembly Computer Organization and Assembly Language: Module 6.
ENEE150 – 0102 ANDREW GOFFIN Dynamic Memory. Dynamic vs Static Allocation Dynamic  On the heap  Amount of memory chosen at runtime  Can change allocated.
Arrays in java Unit-1 Introduction to Java. Array There are situations where we might wish to store a group of similar type of values in a variable. Array.
Pointers as arrays C++ Programming Technologies. Pointers vs. Arrays Pointers and arrays are strongly related. In fact, pointers and arrays are interchangeable.
Eliminating External Fragmentation in a Non-Moving Garbage Collector for Java Author: Fridtjof Siebert, CASES 2000 Michael Sallas Object-Oriented Languages.
MEMORY MANAGEMENT. memory management  In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. 
Memory Management Memory Areas and their use Memory Manager Tasks:
Dynamic Memory Allocation
Day 19 Memory Management.
Memory Management Memory Areas and their use Memory Manager Tasks:
CSCI206 - Computer Organization & Programming
Data Structures and Analysis (COMP 410)
Segmentation Lecture November 2018.
Memory Segments Code (.code) Data (.data) Stack Heap
Main Memory Session - 16.
Lecture 3: Main Memory.
Arrays Week 2.
Introduction to Data Structure
Memory Management Memory Areas and their use Memory Manager Tasks:
Run-time environments
Presentation transcript:

Memory organization and usage A computer’s memory is, at its lowest level, composed of binary digits (bits). The memory is organized into bytes, which are groups of eight bits. Each byte has a unique address in memory. A byte is the smallest addressable unit of memory (i.e. nothing smaller than a byte has its own address)

Memory organization Table at right shows 16 bytes, each consisting of 8 bits Each byte has an address, shown in the column to the left

Memory organization Process BProcess AProcess C

Memory organization Process BProcess AProcess C STATIC SEGMENT RUNTIME STACK FREE/AVAILABLE MEMORY HEAP dynamically allocated memory

Memory organization STATIC SEGMENT RUNTIME STACK FREE/AVAILABLE MEMORY HEAP main(){…methodA()…} methodA(){…methodB()…} methodB() { …methodC()…} methodC(){…} main()

Memory organization STATIC SEGMENT RUNTIME STACK FREE/AVAILABLE MEMORY HEAP main(){…methodA()…} methodA(){…methodB()…} methodB() { …methodC()…} methodC(){…} main()methodA()

Memory organization STATIC SEGMENT RUNTIME STACK FREE/AVAILABLE MEMORY HEAP main(){…methodA()…} methodA(){…methodB()…} methodB() { …methodC()…} methodC(){…} main()methodA()methodB()

Memory organization STATIC SEGMENT RUNTIME STACK FREE/AVAILABLE MEMORY HEAP main(){…methodA()…} methodA(){…methodB()…} methodB() { …methodC()…} methodC(){…} main()methodA()methodB()methodC()

Memory organization STATIC SEGMENT RUNTIME STACK FREE/AVAILABLE MEMORY HEAP main(){…methodA()…} methodA(){…methodB()…} methodB() { …methodC()…} methodC(){…} main()methodA()methodB()

Memory organization STATIC SEGMENT RUNTIME STACK FREE/AVAILABLE MEMORY HEAP main(){…methodA()…} methodA(){…methodB()…} methodB() { …methodC()…} methodC(){…} main()methodA()

Memory organization STATIC SEGMENT RUNTIME STACK FREE/AVAILABLE MEMORY HEAP main(){…methodA()…} methodA(){…methodB()…} methodB() { …methodC()…} methodC(){…} main()

Memory organization Table at right shows 16 bytes, each consisting of 8 bits Each byte has an address, shown in the column to the left

Arrays A collection of variables, all of the same type. Each variable in an array is accessed by an index. An array of size n has indices from 0 to n-1. An array occupies a contiguous block of memory. The size of an array is fixed at creation time.

Accessing an array member t type of elements in array s size (in bytes) of an element of type t b base address of array address of element i is b + i * s

Array access example In Java, an int occupies 4 bytes: int [] a = new int[5]; The base address of ‘a’ is Indices are 0, 1, 2, 3 and 4. Total size needed for array is 20 bytes (5 cells times 4 bytes per cell)

Array access example Where is a[0]? Address of a[0] is: b + s * i where b = , s = 4 and i = 0: * 0 = a[0] occupies bytes , , and a[0]

Array access example Where is a[3]? Address of a[3] is: b + s * i where b = , s = 4 and i = 3: * 3 = a[3] occupies bytes , , and a[3]

Array access example Where is a[7]? There is no such array cell, so what happens if we try to access it? In some languages (e.g. C and C++) the access is permitted, with unpredictable results. Java throws an ArrayIndexOutOfBoundsException