Automatic Memory Management Noam Rinetzky Schreiber 123A 2015/seminar/seminar1415a.html.

Slides:



Advertisements
Similar presentations
Runtime Techniques for Efficient and Reliable Program Execution Harry Xu CS 295 Winter 2012.
Advertisements

Dynamic Memory Management
Introduction to Memory Management. 2 General Structure of Run-Time Memory.
1 Write Barrier Elision for Concurrent Garbage Collectors Martin T. Vechev Cambridge University David F. Bacon IBM T.J.Watson Research Center.
Compilation /15a Lecture 13 Compiling Object-Oriented Programs Noam Rinetzky 1.
CMSC 330: Organization of Programming Languages Memory and Garbage Collection.
Lecture 10: Heap Management CS 540 GMU Spring 2009.
Garbage Collection What is garbage and how can we deal with it?
CMSC 330: Organization of Programming Languages Memory and Garbage Collection.
Background for “KISS: Keep It Simple and Sequential” cs264 Ras Bodik spring 2005.
Bounding Space Usage of Conservative Garbage Collectors Ohad Shacham December 2002 Based on work by Hans-J. Boehm.
MC 2 : High Performance GC for Memory-Constrained Environments - Narendran Sachindran, J. Eliot B. Moss, Emery D. Berger Sowmiya Chocka Narayanan.
Compiler construction in4020 – lecture 12 Koen Langendoen Delft University of Technology The Netherlands.
5. Memory Management From: Chapter 5, Modern Compiler Design, by Dick Grunt et al.
Garbage Collection CSCI 2720 Spring Static vs. Dynamic Allocation Early versions of Fortran –All memory was static C –Mix of static and dynamic.
On-the-Fly Garbage Collection: An Exercise in Cooperation Edsget W. Dijkstra, Leslie Lamport, A.J. Martin and E.F.M. Steffens Communications of the ACM,
Hastings Purify: Fast Detection of Memory Leaks and Access Errors.
Informática II Prof. Dr. Gustavo Patiño MJ
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
CPSC 388 – Compiler Design and Construction
CS 536 Spring Automatic Memory Management Lecture 24.
Chapter 8 Runtime Support. How program structures are implemented in a computer memory? The evolution of programming language design has led to the creation.
1 The Compressor: Concurrent, Incremental and Parallel Compaction. Haim Kermany and Erez Petrank Technion – Israel Institute of Technology.
Memory Management Professor Yihjia Tsai Tamkang University.
Connectivity-Based Garbage Collection Presenter Feng Xian Author Martin Hirzel, et.al Published in OOPSLA’2003.
Runtime The optimized program is ready to run … What sorts of facilities are available at runtime.
1 An Efficient On-the-Fly Cycle Collection Harel Paz, Erez Petrank - Technion, Israel David F. Bacon, V. T. Rajan - IBM T.J. Watson Research Center Elliot.
C and Data Structures Baojian Hua
Garbage collection (& Midterm Topics) David Walker COS 320.
Linked lists and memory allocation Prof. Noah Snavely CS1114
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles C/C++ Emery Berger and Mark Corner University of Massachusetts.
Memory Layout C and Data Structures Baojian Hua
Garbage Collection Memory Management Garbage Collection –Language requirement –VM service –Performance issue in time and space.
A Parallel, Real-Time Garbage Collector Author: Perry Cheng, Guy E. Blelloch Presenter: Jun Tao.
SEG Advanced Software Design and Reengineering TOPIC L Garbage Collection Algorithms.
CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.
Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.
Chapter 0.2 – Pointers and Memory. Type Specifiers  const  may be initialised but not used in any subsequent assignment  common and useful  volatile.
A Mostly Non-Copying Real-Time Collector with Low Overhead and Consistent Utilization David Bacon Perry Cheng (presenting) V.T. Rajan IBM T.J. Watson Research.
Computer Science and Software Engineering University of Wisconsin - Platteville 2. Pointer Yan Shi CS/SE2630 Lecture Notes.
1 Lecture 22 Garbage Collection Mark and Sweep, Stop and Copy, Reference Counting Ras Bodik Shaon Barman Thibaud Hottelier Hack Your Language! CS164: Introduction.
C++ Memory Overview 4 major memory segments Key differences from Java
C++ Data Types Structured array struct union class Address pointer reference Simple IntegralFloating char short int long enum float double long double.
1 Dynamic Memory Allocation –The need –malloc/free –Memory Leaks –Dangling Pointers and Garbage Collection Today’s Material.
Dynamic Memory Allocation. Domain A subset of the total domain name space. A domain represents a level of the hierarchy in the Domain Name Space, and.
Compilation (Semester A, 2013/14) Lecture 13b: Memory Management Noam Rinetzky Slides credit: Eran Yahav 1.
Writing Systems Software in a Functional Language An Experience Report Iavor Diatchki, Thomas Hallgren, Mark Jones, Rebekah Leslie, Andrew Tolmach.
A REAL-TIME GARBAGE COLLECTOR WITH LOW OVERHEAD AND CONSISTENT UTILIZATION David F. Bacon, Perry Cheng, and V.T. Rajan IBM T.J. Watson Research Center.
Runtime The optimized program is ready to run … What sorts of facilities are available at runtime.
Introduction to Garbage Collection. Garbage Collection It automatically reclaims memory occupied by objects that are no longer in use It frees the programmer.
Paper Title Authors names Conference and Year Presented by Your Name Date.
Virtual Machines Noam Rinetzky Schreiber 123A Semester A. Tuesday, 14:00-16:00. Ornstein 110.
Spring, 2011 –– Computational Thinking – Dennis Kafura – CS 2984 Data Structures Mapping complex structures to linear memory.
1 Recall that... char str [ 8 ]; str is the base address of the array. We say str is a pointer because its value is an address. It is a pointer constant.
® July 21, 2004GC Summer School1 Cycles to Recycle: Copy GC Without Stopping the World The Sapphire Collector Richard L. Hudson J. Eliot B. Moss Originally.
CS412/413 Introduction to Compilers and Translators April 21, 1999 Lecture 30: Garbage collection.
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Garbage Collection What is garbage and how can we deal with it?
Dynamic Compilation Vijay Janapa Reddi
Seminar in automatic tools for analyzing programs with dynamic memory
Automatic Memory Management/GC
Automatic Memory Management
Programming with Regions
Strategies for automatic memory management
Memory Management Kathryn McKinley.
Symbolic Execution Tools for Software Testing
Symbolic Execution Tools for Software Testing
CMPE 152: Compiler Design May 2 Class Meeting
Garbage Collection What is garbage and how can we deal with it?
Presentation transcript:

Automatic Memory Management Noam Rinetzky Schreiber 123A /seminar/seminar1415a.html Semester A. Tuesday, 14:00-16:00. Schreiber 7

Scope Automatic algorithms for automatic memory management aka garbage collection – Sequential GC – Parallel GC – Concurrent GC – Real-time GC Focus on correctness

Programs with dynamic memory Programs manipulate resources – Files – Processes / threads – Connections – Memory malloc() / new() free() / delete() …. GC

Programming with dynamic memory typedef struct Data {int d; struct Data *n} Da; main(){ Da *p1 = (Da*) malloc(sizeof(Da)); p1  d = SECRET_KEY; Da *p2 = (Da*) malloc(sizeof(Da)); p2  d = 0; p1  n = p2; p2  n = null; free(p1); free(p2) }

Common mistakes Double free Memory leaks (no-free) Accessing dangling references Null-dereference Breaking invariants – p1  n = p2; p2  n = null; – p1  n = p2; p2  n = p1;

Undesired outcome… Crashes Incorrect behavior Security vulnerabilities Loss of life Loss of money Loss of reputation Loss of Job

Deallocation Allocation is “easy” “Deletion” is hard Nasty bugs Hard to get right – Defensive programming

Controlled Solutions Manual memory management – Runtime: Monitoring execution environment Catches errors Expensive – Compile-time: Verify memory safety Static analysis – Fully automatic / User-provided annotations Conservative – Problem is undecidable

Automatic Memory Management Exploit global knowledge – Hard to de-allocate based on local reasoning Simplifies code, Reduce coupling, Reduces errors, costs Sensitive & Chaotic (Locality, Program)

GC for the rescue Double free Memory leaks (no-free) Accessing dangling references Null-dereference Breaking invariants – p1  n = p2; p2  n = null; – p1  n = p2; p2  n = p1;

GC Runtime environment recycles memory that will not be used in the future of the execution – Cannot be used = unreachable Pros – Safe – Simple Cons – Runtime overhead – Imprecision (drag)

GC Challenges Unbounded number of resources Complicated data structures Efficiency Precision Correctness Multithreading makes things worse!

Comparing GC Algorithms Safety Throughput Completeness and promptness – Pause Space overhead Language-specific optimizations Scalability and portability

More issues Performance overhead Experimental methodology

Terminology Heap Mutator & Collector Mutator roots References, fields, addresses Liveness, correctness, reachability Allocator

Schedule ChapterTopicDateLesson Chap.1Overview Chap. 2,3Mark-and-Sweep and Mark-compact GC Chap. 4,5Copying GC and reference counting Chap. 6,7Comparing GCs and allocation Chap. 8,9,10Partitioning and generational GC Chap. 11,12Runtime interface and language specific concerns Chap. 13Concurrency preliminaries Chap. 14Parallel GC Chap. 15Concurrent GC Chap. 16Concurrent mark-sweep GC Chap. 17Concurrent copying and compaction GC Chap. 18Concurrent reference-counting Chap. 19Real-time GC

Admin

Requirements You are required to be present in every lesson – unless coordinated ahead with the lecturer Meet me before lecture – Sunday , Schreiber 123A

Requirements Give a 80 minutes talk about his or hers assigned topic. Answer students questions during the talk. Say something original Lead a discussion a summary discussion. Write a short (1 page) summary Participate in the discussions

Grades 70% Presentation 5% Original insight 10% Participation 15% Attendance

Paper Title Names of Authors Your Name + date

Outline of talk Introduction Suggested Solution Evaluation Related work Conclusions Your own conclusions

Introduction Problem area Technical challenged addressed Why is it important What is the main insight How is main insight utilized (high level)

Solution Technical description – Algorithm – Correctness – Complexity Choose key subset of details Use examples + diagrams

Evaluation Experiments Benchmarks Conclusions

Related work What other solutions are out there How do they compare – Pros – Cons

Conclusions What was done Why is it important Novel idea What we learned

Your own conclusion Surprise me