CSC 253 Lecture 8.

Slides:



Advertisements
Similar presentations
Dynamic Memory Allocation (also see pointers lectures) -L. Grewe.
Advertisements

10/6: Lecture Topics Procedure call Calling conventions The stack
Run-Time Storage Organization
Memory and C++ Pointers.  C++ objects and memory  C++ primitive types and memory  Note: “primitive types” = int, long, float, double, char, … January.
Chapter 7: Runtime Environment –Run time memory organization. We need to use memory to store: –code –static data (global variables) –dynamic data objects.
Presented by: Mojtaba Khezrian. Agenda Object Creation Object Storage More on Arrays Parameter Passing For Each VarArgs Spring 2014Sharif University of.
Runtime Environments Compiler Construction Chapter 7.
Chapter 5: Programming Languages and Constructs by Ravi Sethi Activation Records Dolores Zage.
February 11, 2005 More Pointers Dynamic Memory Allocation.
Peyman Dodangeh Sharif University of Technology Fall 2013.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
1 Homework HW5 due today Review a lot of things about allocation of storage that may not have been clear when we covered them in our initial pass Introduction.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
1 Workin’ with Pointas An exercise in destroying your computer.
Pointers in C Computer Organization I 1 August 2009 © McQuain, Feng & Ribbens Memory and Addresses Memory is just a sequence of byte-sized.
Department of Electronic & Electrical Engineering Functions Parameters Arguments Pointers/dereference & * Scope Global/Local Storage Static/Automatic.
POINTERS IN C. Introduction  A pointer is a variable that holds a memory address  This address is the location of another object (typically another.
“Success consists of going from failure to failure without loss of enthusiasm.” Winston Churchill.
POINTERS AND MEMORY ACKNOWLEDGEMENT: THE SLIDES ARE PREPARED FROM SLIDES PROVIDED BY NANCY M. AMATO AND JORY DENNY 1.
Variables Bryce Boe 2012/09/05 CS32, Summer 2012 B.
CMSC 341 Lecture 2 – Dynamic Memory and Pointers (Review)
Stack and Heap Memory Stack resident variables include:
Run-Time Environments Chapter 7
Overview 4 major memory segments Key differences from Java stack
COM S 326X Deep C Programming for the 21st Century Prof. Rozier
Review: Chapter 5: Syntax directed translation
Run-Time Storage Organization
Run-Time Storage Organization
Procedures (Functions)
C++ Interlude 2 Pointers, Polymorphism, and Memory Allocation
This pointer, Dynamic memory allocation, Constructors and Destructor
Advanced Programming Behnam Hatami Fall 2017.
Dynamic Memory Allocation
Dynamic Memory Allocation
CSC 253 Lecture 8.
Overview 4 major memory segments Key differences from Java stack
understanding memory usage by a c++ program
Memory Segments Code (.code) Data (.data) Stack Heap
Overview of Memory Layout in C++
Pointers, Dynamic Data, and Reference Types
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Understanding Program Address Space
Pointers And Memory Acknowledgement: THE Slides are Prepared FROM SLIDES PROVIDED By NANCY M. AMATO AND Jory Denny.
CSC 253 Lecture 7.
Dynamic Memory A whole heap of fun….
Pointers The C programming language gives us the ability to directly manipulate the contents of memory addresses via pointers. Unfortunately, this power.
Binding Times Binding is an association between two things Examples:
Dynamic Memory A whole heap of fun….
Pointers and Arrays Beyond Chapter 16
Lecture 18: Deep C Garbage Collection CS201j: Engineering Software
UNIT V Run Time Environments.
C (and C++) Pointers April 4, 2019.
Pointers Pointers point to memory locations
CSC 253 Lecture 2.
Dynamic Memory A whole heap of fun….
Dynamic Memory.
C Programming Pointers
Chapter 9: Pointers and String
Pointers and dynamic objects
C H A P T E R F I V E Memory Management.
The Stack.
Pointers and References
Destructors, Copy Constructors & Copy Assignment Operators
Pointers, Dynamic Data, and Reference Types
Destructors, Copy Constructors & Copy Assignment Operators
Basic Guarantees Right off the bat… what I'm going to describe is what almost certainly happens on contemporary machines, but there is absolutely nothing.
C Programming Lecture-17 Storage Classes
Run-time environments
Variable Storage Memory Locations (Logical) Variable Classes Stack
SPL – PS2 C++ Memory Handling.
Presentation transcript:

CSC 253 Lecture 8

What regions can hold our data? A. Stack, static, and extern B. Stack, heap, and static C. Stack and heap D. Local and static E. Local, static and extern

Why do we need heap storage? A. To make sure we don’t run out of memory. B. To allow variables to outlast procedure calls & returns. C. To give us a place to allocate arrays D. Both A and C.

Pointers to variables on the stack Declare a non-pointer variable. Declare a pointer variable. Set the pointer to point to the non-pointer.

Pointers to variables on the heap (See 2.c)

What happens if we increment a pointer? (also in 2.c)

Incrementing pointer vs. incrementing value pointed to (also in 2.c)

Let’s make our printing code into a procedure What parameters would we pass? What type is the first parameter? What type is the second parameter? int int* int & Char (See 3.c)

Why use handles?