Opera&ng Systems CMPSCI 377 Garbage Collec&on. Emery Berger and Mark Corner University of Massachuse9s Amherst

Size: px
Start display at page:

Download "Opera&ng Systems CMPSCI 377 Garbage Collec&on. Emery Berger and Mark Corner University of Massachuse9s Amherst"

Transcription

1 Opera&ng Systems CMPSCI 377 Garbage Collec&on Emery Berger and Mark Corner University of Massachuse9s Amherst

2 Ques<ons To Come Terms: Tracing Copying Conserva&ve Parallel GC Concurrent GC Run&me & space costs Live objects Reachable objects References 2

3 Explicit Memory Management malloc/new allocates space for an object free/delete returns memory to system Simple, but tricky to get right Forget to free memory leak free too soon dangling pointer Double free, invalid free...

4 Dangling Pointers Node x = new Node ( happy ); Node ptr = x; delete x; // But I m not dead yet! Node y = new Node ( sad ); cout << ptr- >data << endl; // sad Insidious, hard- to- track down bugs

5 Solu<on: Garbage Collec<on Garbage collector periodically scans Looks at all objects on heap No need to free Automa&c memory management Reclaims non- reachable objects Won t reclaim objects un&l they re dead (actually somewhat later)

6 No More Dangling Pointers Node x = new Node ( happy ); Node ptr = x; // x s&ll live (reachable through ptr) Node y = new Node ( sad ); cout << ptr- >data << endl; // happy! So why not use GC all the time?

7 Because This Guy Says Not To Linus Torvalds There just aren t all GC that sucks many donkey worse brains ways through to f*** a up straw your from cache a performance behavior than standpoint. by using lots of allocations and lazy GC to manage your memory.

8 One side of the argument GC impairs performance Extra processing collec&on, copying Degrades cache performance Degrades page locality Increases memory needs delayed reclama&on

9 On the other hand No, GC enhances performance! Faster alloca&on pointer- bumping vs. freelists Improves cache performance no need for headers Beaer locality can reduce fragmenta&on, compact data structures according to use

10 Outline Classical GC algorithms Quan&fying GC performance A hard problem Oracular memory management GC vs. malloc/free bakeoff

11 Classical Algorithms Three classical algorithms Mark- sweep Reference coun&ng Semispace Tweaks Genera&onal garbage collec&on Out of scope Parallel perform GC in parallel Concurrent run GC at same &me as app Real- &me ensure bounded pause &mes 11

12 Mark- Sweep Start with roots Global variables, variables on stack & in registers Recursively visit every object through pointers Mark every object we find (set mark bit) Everything not marked = garbage Can then sweep heap for unmarked objects and free them 12

13 Mark- Sweep Example roots global 1 global 2 global 3 object 1 object 2 object 3 object 4 object 5 object 6 Ini&ally, all objects white (garbage) 13

14 Mark- Sweep Example roots global 1 global 2 global 3 object 1 object 2 object 3 object 4 object 5 object 6 Ini&ally, all objects white (garbage) Visit objects, following object graph 14

15 Mark- Sweep Example roots global 1 global 2 global 3 object 1 object 2 object 3 object 4 object 5 object 6 Ini&ally, all objects white (garbage) Visit objects, following object graph 15

16 Mark- Sweep Example roots global 1 global 2 global 3 object 1 object 2 object 3 object 4 object 5 object 6 Ini&ally, all objects white (garbage) Visit objects, following object graph 16

17 Mark- Sweep Example roots global 1 global 2 global 3 freelist object 1 object 2 object 3 object 4 object 5 object 6 Ini&ally, all objects white (garbage) Visit objects, following object graph Can sweep immediately or lazily 17

18 Reference Coun<ng For every object, maintain reference count = number of incoming pointers a- >ptr = x refcount(x)++ a- >ptr = y refcount(x)- - ; refcount(y)++ Reference count = 0 no more incoming pointers: garbage 18

19 Reference Coun<ng Example roots global 1 global 2 global object 2 object 4 object 5 New objects: ref count = 1 19

20 Reference Coun<ng Example roots global 1 global 2 global object 2 object 4 object 5 New objects: ref count = 1 Delete pointer: refcount- - 20

21 Reference Coun<ng Example roots global 1 global 2 global object 2 object 4 object 5 New objects: ref count = 1 Delete pointer: refcount- - 21

22 Reference Coun<ng Example roots global 1 global 2 global object 2 object 4 object 5 New objects: ref count = 1 Delete pointer: refcount- - And recursively delete pointers 22

23 Reference Coun<ng Example roots global 1 global 2 global object 2 object 4 object 5 New objects: ref count = 1 Delete pointer: refcount- - And recursively delete pointers refcount == 0: put on freelist 23

24 Quick Ac<vity roots global 1 global 2 global object 2 object 4 object 5 What could go wrong with ref coun&ng? How could you fix it? 24

25 Cycles & Reference Coun<ng roots global 1 global 2 global object 2 object 4 object 5 Big problem: cycles 25

26 Reference Coun<ng Example roots global 1 global 2 global object 2 object 4 object 5 Big problem: cycles 26

27 Reference Coun<ng Example roots global 1 global 2 global object 2 object 4 object 5 Big problem: cycles Cycles lead to unreclaimable garbage Need to do periodic tracing collec&on (e.g., mark- sweep) 27

28 Semispace Divide heap in two semispaces: Allocate objects from from- space When from- space fills, Scan from roots through live objects Copy them into to- space When done, switch the spaces Allocate from lepover part of to- space 28

29 Semispace Example from- space Allocate in from- space Pointer bumping to- space 29

30 Semispace Example from- space Allocate in from- space Pointer bumping to- space 30

31 Semispace Example from- space Allocate in from- space Pointer bumping to- space 31

32 Semispace Example from- space Allocate in from- space Pointer bumping Copy live objects into to- space to- space 32

33 Semispace Example from- space to- space Allocate in from- space Pointer bumping Copy live objects into to- space Leaves forwarding pointer 33

34 Semispace Example from- space to- space Allocate in from- space Pointer bumping Copy live objects into to- space Leaves forwarding pointer 34

35 Semispace Example from- space to- space Allocate in from- space Pointer bumping Copy live objects into to- space Leaves forwarding pointer 35

36 Semispace Example to- space from- space Allocate in from- space Pointer bumping Copy live objects into to- space Leaves forwarding pointer Flip spaces; allocate from end 36

37 Genera<onal GC Op&miza&on for copying collectors Genera&onal hypothesis: most objects die young Common- case op&miza&on Allocate into nursery Small region Collect frequently Copy out survivors Key idea: keep track of pointers from mature space into nursery 37

38 Genera<onal GC Example mature space nursery 38

39 Genera<onal GC Example mature space nursery 39

40 Genera<onal GC Example mature space nursery 40

41 Genera<onal GC Example mature space Copy out survivors (via roots & mature space pointers) nursery 41

42 Genera<onal GC Example mature space Copy out survivors (via roots & mature space pointers) nursery 42

43 Genera<onal GC Example mature space Copy out survivors (via roots & mature space pointers) nursery 43

44 Genera<onal GC Example mature space Copy out survivors (via roots & mature space pointers) Reset alloca&on pointer & con&nue nursery 44

45 Conserva<ve GC Non- copying collectors for C & C++ Must iden&fy pointers Duck test : if it looks like a pointer, it s a pointer Trace through pointers, marking everything Can link with Boehm- Demers- Weiser library ( libgc ) 45

46 Comparing GC to Malloc Omit details of how to do this It s complicated Depends on the language Assume perfect malloc Free right when done

47 Geo. Mean of Execu<on Time 130% 125% GenMS GenCopy GenRC Lea w/ Reach Lea w/ Life MSExplicit w/ Reach 120% Execution Time Relative to Lea 115% 110% 105% 100% 95% 90% Heap Size Relative to Collector Minimum Trades space for &me

48 Summary of Results Best collector equals Lea's performance Up to 10% faster on some benchmarks... but uses more memory Quickest runs require 5x or more memory GenMS at least doubles mean footprint

49 When to Use Garbage Collec<on Garbage collec&on fine if system has more than 3x needed RAM and no compe&&on with other processes or avoiding bugs / security more important Not so good: Limited RAM Compe&&on for physical memory Depends on RAM for performance In- memory database Search engines, etc.

50 The End 50

51 GC vs. malloc/free 51

52 Comparing Memory Managers Node v = malloc(sizeof(node)); v->data=malloc(sizeof(nodedata)); memcpy(v->data, old->data, sizeof(nodedata)); free(old->data); v->next = old->next; v->next->prev = v; v->prev = old->prev; v->prev->next = v; free(old); BDW Collector Using GC in C/C++ is easy:

53 Comparing Memory Managers Node v = malloc(sizeof(node)); v->data=malloc(sizeof(nodedata)); memcpy(v->data, old->data, sizeof(nodedata)); free(old->data); v->next = old->next; v->next->prev = v; v->prev = old->prev; v->prev->next = v; free(old); BDW Collector slide in BDW and ignore calls to free.

54 What About Other Garbage Collectors? Compares malloc to GC, but only conserva3ve, non- copying collectors Can t reduce fragmenta&on, reorder objects, etc. But: faster precise, copying collectors Incompa&ble with C/C++ Standard for Java

55 Comparing Memory Managers Node node = new Node(); node.data = new NodeData(); usenode(node); node = null;... node = new Node();... node.data = new NodeData();... Lea Allocator Adding malloc/free to Java: not so easy

56 Comparing Memory Managers Node node = new Node(); node.data = new NodeData(); usenode(node); node = null;... node = new Node(); free (node)? free(node.data)?... node.data = new NodeData();... Lea Allocator... need to insert frees, but where?

57 Oracular Memory Manager Java C malloc/free execute program here Simulator alloca3on perform actions at no cost below here Oracle Consult oracle at each alloca&on Oracle does not disrupt hardware state Simulator invokes free()

58 Object Life&me & Oracle Placement obj = new Object; live reachable freed can be by freed lifetimebased oracle freed by reachabilitybased oracle free(obj) free(obj) free(??) can be collected dead unreachable Oracles bracket placement of frees Life<me- based: most aggressive Reachability- based: most conserva&ve

59 Liveness Oracle Genera&on Java C malloc/ free execute program here alloca3on, mem access, prog. roots PowerPC Simulator perform actions at no cost below here trace file Post- process Oracle Liveness: record allocs, memory accesses

60 Reachability Oracle Genera&on Java C malloc/ free execute program here alloca3ons, ptr updates, prog. roots PowerPC Simulator perform actions at no cost below here trace file Merlin analysis Oracle Reachability: Illegal instruc&ons mark heap events (especially pointer assignments)

61 Oracular Memory Manager Java C malloc/ free execute program here PowerPC Simulator alloca3on perform actions at no cost below here oracle Run & consult oracle before each alloca&on When needed, modify instruc&on to call free Extra costs (oracle access) hidden by simulator

62 Execu&on Time for pseudojbb 150% GenM S 140% GenCopy GenRC Lea w/ Reach Lea w/ Life 130% 120% 110% 100% 90% Heap Size Relative to Collector Minimum GC can be faster than malloc/free

63 Footprint at Quickest Run 800% 700% 600% 500% 400% 300% 200% 100% 0% Lea w/ Reach Lea w/ Life MMTk Kingsley GenMS GenCopy CopyMS SemiSpace MarkSweep GC uses much more memory for speed

64 Footprint at Quickest Run 800% 700% % 500% % 300% 200% 100% % Lea w/ Reach Lea w/ Life MMTk Kingsley GenMS GenCopy CopyMS SemiSpace MarkSweep GC uses much more memory for speed

65 Javac Paging Performance GC: poor paging performance

Quantifying the Performance of Garbage Collection vs. Explicit Memory Management

Quantifying the Performance of Garbage Collection vs. Explicit Memory Management Quantifying the Performance of Garbage Collection vs. Explicit Memory Management Matthew Hertz Canisius College Emery Berger University of Massachusetts Amherst Explicit Memory Management malloc / new

More information

Garbage Collection Techniques

Garbage Collection Techniques Garbage Collection Techniques Michael Jantz COSC 340: Software Engineering 1 Memory Management Memory Management Recognizing when allocated objects are no longer needed Deallocating (freeing) the memory

More information

Runtime. The optimized program is ready to run What sorts of facilities are available at runtime

Runtime. The optimized program is ready to run What sorts of facilities are available at runtime Runtime The optimized program is ready to run What sorts of facilities are available at runtime Compiler Passes Analysis of input program (front-end) character stream Lexical Analysis token stream Syntactic

More information

Myths and Realities: The Performance Impact of Garbage Collection

Myths and Realities: The Performance Impact of Garbage Collection Myths and Realities: The Performance Impact of Garbage Collection Tapasya Patki February 17, 2011 1 Motivation Automatic memory management has numerous software engineering benefits from the developer

More information

Acknowledgements These slides are based on Kathryn McKinley s slides on garbage collection as well as E Christopher Lewis s slides

Acknowledgements These slides are based on Kathryn McKinley s slides on garbage collection as well as E Christopher Lewis s slides Garbage Collection Last time Compiling Object-Oriented Languages Today Motivation behind garbage collection Garbage collection basics Garbage collection performance Specific example of using GC in C++

More information

Programming Language Implementation

Programming Language Implementation A Practical Introduction to Programming Language Implementation 2014: Week 10 Garbage Collection College of Information Science and Engineering Ritsumeikan University 1 review of last week s topics dynamic

More information

Lecture 15 Garbage Collection

Lecture 15 Garbage Collection Lecture 15 Garbage Collection I. Introduction to GC -- Reference Counting -- Basic Trace-Based GC II. Copying Collectors III. Break Up GC in Time (Incremental) IV. Break Up GC in Space (Partial) Readings:

More information

Managed runtimes & garbage collection. CSE 6341 Some slides by Kathryn McKinley

Managed runtimes & garbage collection. CSE 6341 Some slides by Kathryn McKinley Managed runtimes & garbage collection CSE 6341 Some slides by Kathryn McKinley 1 Managed runtimes Advantages? Disadvantages? 2 Managed runtimes Advantages? Reliability Security Portability Performance?

More information

Managed runtimes & garbage collection

Managed runtimes & garbage collection Managed runtimes Advantages? Managed runtimes & garbage collection CSE 631 Some slides by Kathryn McKinley Disadvantages? 1 2 Managed runtimes Portability (& performance) Advantages? Reliability Security

More information

Binghamton University Dynamic Memory Alloca/on

Binghamton University Dynamic Memory Alloca/on Dynamic Memory Alloca/on Slides credit: Presenta/on based on slides by Dave O halloran/csapp 1 Dynamic memory alloca/on Where is this important? Heap Kernel heap Physical memory allocator Problems are

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Memory Management and Garbage Collection CMSC 330 - Spring 2013 1 Memory Attributes! Memory to store data in programming languages has the following lifecycle

More information

CS 345. Garbage Collection. Vitaly Shmatikov. slide 1

CS 345. Garbage Collection. Vitaly Shmatikov. slide 1 CS 345 Garbage Collection Vitaly Shmatikov slide 1 Major Areas of Memory Static area Fixed size, fixed content, allocated at compile time Run-time stack Variable size, variable content (activation records)

More information

Dynamic Memory Alloca/on: Advanced Concepts

Dynamic Memory Alloca/on: Advanced Concepts Dynamic Memory Alloca/on: Advanced Concepts CS 485 Systems Programming Fall 2015 Instructor: James Griffioen Adapted from slides by R. Bryant and D. O Hallaron (hip://csapp.cs.cmu.edu/public/instructors.html)

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Memory Management and Garbage Collection CMSC 330 Spring 2017 1 Memory Attributes Memory to store data in programming languages has the following lifecycle

More information

CMSC 330: Organization of Programming Languages. Memory Management and Garbage Collection

CMSC 330: Organization of Programming Languages. Memory Management and Garbage Collection CMSC 330: Organization of Programming Languages Memory Management and Garbage Collection CMSC330 Fall 2018 1 Memory Attributes Memory to store data in programming languages has the following lifecycle

More information

Opera&ng Systems CMPSCI 377 Dynamic Memory Management. Emery Berger and Mark Corner University of Massachuse9s Amherst

Opera&ng Systems CMPSCI 377 Dynamic Memory Management. Emery Berger and Mark Corner University of Massachuse9s Amherst Opera&ng Systems CMPSCI 377 Dynamic Memory Management Emery Berger and Mark Corner University of Massachuse9s Amherst Dynamic Memory Management How the heap manager is implemented malloc, free new, delete

More information

Free-Me: A Static Analysis for Automatic Individual Object Reclamation

Free-Me: A Static Analysis for Automatic Individual Object Reclamation Free-Me: A Static Analysis for Automatic Individual Object Reclamation Samuel Z. Guyer, Kathryn McKinley, Daniel Frampton Presented by: Jason VanFickell Thanks to Dimitris Prountzos for slides adapted

More information

Chapter 4: Memory. Taylor & Francis Adair Dingle All Rights Reserved

Chapter 4: Memory. Taylor & Francis Adair Dingle All Rights Reserved Chapter 4: Memory Program Memory Overview Analysis of the impact of design on memory use Memory Abstrac9on Heap Memory Memory Overhead Memory Management Programmer s Perspec9ve Standard Views of Memory

More information

Garbage Collection. Steven R. Bagley

Garbage Collection. Steven R. Bagley Garbage Collection Steven R. Bagley Reference Counting Counts number of pointers to an Object deleted when the count hits zero Eager deleted as soon as it is finished with Problem: Circular references

More information

Lecture 13: Garbage Collection

Lecture 13: Garbage Collection Lecture 13: Garbage Collection COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer/Mikkel Kringelbach 1 Garbage Collection Every modern programming language allows programmers

More information

Performance of Non-Moving Garbage Collectors. Hans-J. Boehm HP Labs

Performance of Non-Moving Garbage Collectors. Hans-J. Boehm HP Labs Performance of Non-Moving Garbage Collectors Hans-J. Boehm HP Labs Why Use (Tracing) Garbage Collection to Reclaim Program Memory? Increasingly common Java, C#, Scheme, Python, ML,... gcc, w3m, emacs,

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 2 Thomas Wies New York University Review Last week Programming Languages Overview Syntax and Semantics Grammars and Regular Expressions High-level

More information

Garbage Collection. Hwansoo Han

Garbage Collection. Hwansoo Han Garbage Collection Hwansoo Han Heap Memory Garbage collection Automatically reclaim the space that the running program can never access again Performed by the runtime system Two parts of a garbage collector

More information

Garbage Collection. Akim D le, Etienne Renault, Roland Levillain. May 15, CCMP2 Garbage Collection May 15, / 35

Garbage Collection. Akim D le, Etienne Renault, Roland Levillain. May 15, CCMP2 Garbage Collection May 15, / 35 Garbage Collection Akim Demaille, Etienne Renault, Roland Levillain May 15, 2017 CCMP2 Garbage Collection May 15, 2017 1 / 35 Table of contents 1 Motivations and Definitions 2 Reference Counting Garbage

More information

Exploiting the Behavior of Generational Garbage Collector

Exploiting the Behavior of Generational Garbage Collector Exploiting the Behavior of Generational Garbage Collector I. Introduction Zhe Xu, Jia Zhao Garbage collection is a form of automatic memory management. The garbage collector, attempts to reclaim garbage,

More information

Garbage Collection. Weiyuan Li

Garbage Collection. Weiyuan Li Garbage Collection Weiyuan Li Why GC exactly? - Laziness - Performance - free is not free - combats memory fragmentation - More flame wars Basic concepts - Type Safety - Safe: ML, Java (not really) - Unsafe:

More information

Automatic Memory Management

Automatic Memory Management Automatic Memory Management Why Automatic Memory Management? Storage management is still a hard problem in modern programming Why Automatic Memory Management? Storage management is still a hard problem

More information

One-Slide Summary. Lecture Outine. Automatic Memory Management #1. Why Automatic Memory Management? Garbage Collection.

One-Slide Summary. Lecture Outine. Automatic Memory Management #1. Why Automatic Memory Management? Garbage Collection. Automatic Memory Management #1 One-Slide Summary An automatic memory management system deallocates objects when they are no longer used and reclaims their storage space. We must be conservative and only

More information

QUANTIFYING AND IMPROVING THE PERFORMANCE OF GARBAGE COLLECTION

QUANTIFYING AND IMPROVING THE PERFORMANCE OF GARBAGE COLLECTION QUANTIFYING AND IMPROVING THE PERFORMANCE OF GARBAGE COLLECTION A Dissertation Presented by MATTHEW HERTZ Submitted to the Graduate School of the University of Massachusetts Amherst in partial fulfillment

More information

Dynamic Memory Alloca/on: Advanced Concepts

Dynamic Memory Alloca/on: Advanced Concepts Dynamic Memory Alloca/on: Advanced Concepts 15-213: Introduc0on to Computer Systems 18 th Lecture, Oct. 26, 2010 Instructors: Randy Bryant and Dave O Hallaron 1 Today Explicit free lists Segregated free

More information

Garbage Collection (1)

Garbage Collection (1) Garbage Collection (1) Advanced Operating Systems Lecture 7 This work is licensed under the Creative Commons Attribution-NoDerivatives 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/4.0/

More information

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8 Subroutines and Control Abstraction Textbook, Chapter 8 1 Subroutines and Control Abstraction Mechanisms for process abstraction Single entry (except FORTRAN, PL/I) Caller is suspended Control returns

More information

A new Mono GC. Paolo Molaro October 25, 2006

A new Mono GC. Paolo Molaro October 25, 2006 A new Mono GC Paolo Molaro lupus@novell.com October 25, 2006 Current GC: why Boehm Ported to the major architectures and systems Featurefull Very easy to integrate Handles managed pointers in unmanaged

More information

Memory Management. CS449 Fall 2017

Memory Management. CS449 Fall 2017 Memory Management CS449 Fall 2017 Life9mes Life9me: 9me from which a par9cular memory loca9on is allocated un9l it is deallocated Three types of life9mes Automa9c (within a scope) Sta9c (dura9on of program)

More information

CS842: Automatic Memory Management and Garbage Collection. Mark and sweep

CS842: Automatic Memory Management and Garbage Collection. Mark and sweep CS842: Automatic Memory Management and Garbage Collection Mark and sweep 1 Schedule M W Sept 14 Intro/Background Basics/ideas Sept 21 Allocation/layout GGGGC Sept 28 Mark/Sweep Mark/Sweep cto 5 Copying

More information

Deallocation Mechanisms. User-controlled Deallocation. Automatic Garbage Collection

Deallocation Mechanisms. User-controlled Deallocation. Automatic Garbage Collection Deallocation Mechanisms User-controlled Deallocation Allocating heap space is fairly easy. But how do we deallocate heap memory no longer in use? Sometimes we may never need to deallocate! If heaps objects

More information

CS Computer Systems. Lecture 8: Free Memory Management

CS Computer Systems. Lecture 8: Free Memory Management CS 5600 Computer Systems Lecture 8: Free Memory Management Recap of Last Week Last week focused on virtual memory Gives each process the illusion of vast, empty memory Offers protection and isolation 31

More information

Garbage Collection. Vyacheslav Egorov

Garbage Collection. Vyacheslav Egorov Garbage Collection Vyacheslav Egorov 28.02.2012 class Heap { public: void* Allocate(size_t sz); }; class Heap { public: void* Allocate(size_t sz); void Deallocate(void* ptr); }; class Heap { public: void*

More information

Run-time Environments -Part 3

Run-time Environments -Part 3 Run-time Environments -Part 3 Y.N. Srikant Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course on Compiler Design Outline of the Lecture Part 3 What is run-time support?

More information

Heap Management. Heap Allocation

Heap Management. Heap Allocation Heap Management Heap Allocation A very flexible storage allocation mechanism is heap allocation. Any number of data objects can be allocated and freed in a memory pool, called a heap. Heap allocation is

More information

CS 241 Honors Memory

CS 241 Honors Memory CS 241 Honors Memory Ben Kurtovic Atul Sandur Bhuvan Venkatesh Brian Zhou Kevin Hong University of Illinois Urbana Champaign February 20, 2018 CS 241 Course Staff (UIUC) Memory February 20, 2018 1 / 35

More information

NAMES, SCOPES AND BINDING A REVIEW OF THE CONCEPTS

NAMES, SCOPES AND BINDING A REVIEW OF THE CONCEPTS NAMES, SCOPES AND BINDING A REVIEW OF THE CONCEPTS Name Binding and Binding Time Name binding is the associa1on of objects (data and/or code) with names (iden1fiers) Shape S = new Shape(); The binding

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c/su06 CS61C : Machine Structures Lecture #6: Memory Management CS 61C L06 Memory Management (1) 2006-07-05 Andy Carle Memory Management (1/2) Variable declaration allocates

More information

Lecture Notes on Garbage Collection

Lecture Notes on Garbage Collection Lecture Notes on Garbage Collection 15-411: Compiler Design Frank Pfenning Lecture 21 November 4, 2014 These brief notes only contain a short overview, a few pointers to the literature with detailed descriptions,

More information

Implementation Garbage Collection

Implementation Garbage Collection CITS 3242 Programming Paradigms Part IV: Advanced Topics Topic 19: Implementation Garbage Collection Most languages in the functional, logic, and object-oriented paradigms include some form of automatic

More information

CS2210: Compiler Construction. Runtime Environment

CS2210: Compiler Construction. Runtime Environment : The environment in which the program executes in at runtime Includes HW: Main memory, CPU,... Includes OS: Environment variables,... When a program is invoked The OS allocates memory for the program

More information

Robust Memory Management Schemes

Robust Memory Management Schemes Robust Memory Management Schemes Prepared by : Fadi Sbahi & Ali Bsoul Supervised By: Dr. Lo ai Tawalbeh Jordan University of Science and Technology Robust Memory Management Schemes Introduction. Memory

More information

Ulterior Reference Counting: Fast Garbage Collection without a Long Wait

Ulterior Reference Counting: Fast Garbage Collection without a Long Wait Ulterior Reference Counting: Fast Garbage Collection without a Long Wait ABSTRACT Stephen M Blackburn Department of Computer Science Australian National University Canberra, ACT, 000, Australia Steve.Blackburn@anu.edu.au

More information

Memory Management. Memory Management... Memory Management... Interface to Dynamic allocation

Memory Management. Memory Management... Memory Management... Interface to Dynamic allocation CSc 453 Compilers and Systems Software 24 : Garbage Collection Introduction Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2009 Christian Collberg Dynamic Memory Management

More information

ACM Trivia Bowl. Thursday April 3 rd (two days from now) 7pm OLS 001 Snacks and drinks provided All are welcome! I will be there.

ACM Trivia Bowl. Thursday April 3 rd (two days from now) 7pm OLS 001 Snacks and drinks provided All are welcome! I will be there. #1 ACM Trivia Bowl Thursday April 3 rd (two days from now) 7pm OLS 001 Snacks and drinks provided All are welcome! I will be there. If you are in one of the top three teams, I will give you one point of

More information

CS 4120 Lecture 37 Memory Management 28 November 2011 Lecturer: Andrew Myers

CS 4120 Lecture 37 Memory Management 28 November 2011 Lecturer: Andrew Myers CS 4120 Lecture 37 Memory Management 28 November 2011 Lecturer: Andrew Myers Heap allocation is a necessity for modern programming tasks, and so is automatic reclamation of heapallocated memory. However,

More information

Garbage Collection Algorithms. Ganesh Bikshandi

Garbage Collection Algorithms. Ganesh Bikshandi Garbage Collection Algorithms Ganesh Bikshandi Announcement MP4 posted Term paper posted Introduction Garbage : discarded or useless material Collection : the act or process of collecting Garbage collection

More information

Garbage Collection. CS 351: Systems Programming Michael Saelee

Garbage Collection. CS 351: Systems Programming Michael Saelee Garbage Collection CS 351: Systems Programming Michael Saelee = automatic deallocation i.e., malloc, but no free! system must track status of allocated blocks free (and potentially reuse)

More information

Run-Time Environments/Garbage Collection

Run-Time Environments/Garbage Collection Run-Time Environments/Garbage Collection Department of Computer Science, Faculty of ICT January 5, 2014 Introduction Compilers need to be aware of the run-time environment in which their compiled programs

More information

Shenandoah An ultra-low pause time Garbage Collector for OpenJDK. Christine H. Flood Roman Kennke

Shenandoah An ultra-low pause time Garbage Collector for OpenJDK. Christine H. Flood Roman Kennke Shenandoah An ultra-low pause time Garbage Collector for OpenJDK Christine H. Flood Roman Kennke 1 What does ultra-low pause time mean? It means that the pause time is proportional to the size of the root

More information

Heap Compression for Memory-Constrained Java

Heap Compression for Memory-Constrained Java Heap Compression for Memory-Constrained Java CSE Department, PSU G. Chen M. Kandemir N. Vijaykrishnan M. J. Irwin Sun Microsystems B. Mathiske M. Wolczko OOPSLA 03 October 26-30 2003 Overview PROBLEM:

More information

Automatic Garbage Collection

Automatic Garbage Collection Automatic Garbage Collection Announcements: PS6 due Monday 12/6 at 11:59PM Final exam on Thursday 12/16 o PS6 tournament and review session that week Garbage In OCaml programs (and in most other programming

More information

CRAMM: Virtual Memory Support for Garbage-Collected Applications

CRAMM: Virtual Memory Support for Garbage-Collected Applications CRAMM: Virtual Memory Support for Garbage-Collected Applications Ting Yang Emery D. Berger Scott F. Kaplan J. Eliot B. Moss tingy@cs.umass.edu emery@cs.umass.edu sfkaplan@cs.amherst.edu moss@cs.umass.edu

More information

Dynamic Memory Alloca/on: Basic Concepts

Dynamic Memory Alloca/on: Basic Concepts Dynamic Memory Alloca/on: Basic Concepts 15-213 / 18-213: Introduc2on to Computer Systems 18 th Lecture, March. 26, 2013 Instructors: Anthony Rowe, Seth Goldstein, and Gregory Kesden 1 Today Basic concepts

More information

Dynamic Memory Allocation: Advanced Concepts

Dynamic Memory Allocation: Advanced Concepts Dynamic Memory Allocation: Advanced Concepts Keeping Track of Free Blocks Method 1: Implicit list using length links all blocks 5 4 6 Method : Explicit list among the free blocks using pointers 5 4 6 Kai

More information

Harmony GC Source Code

Harmony GC Source Code Harmony GC Source Code -- A Quick Hacking Guide Xiao-Feng Li 2008-4-9 Source Tree Structure Under ${harmony}/working_vm/vm/gc_gen src/ : the major part of source code Has multiple GC algorithms The rest

More information

Sustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java)

Sustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java) COMP 412 FALL 2017 Sustainable Memory Use Allocation & (Implicit) Deallocation (mostly in Java) Copyright 2017, Keith D. Cooper & Zoran Budimlić, all rights reserved. Students enrolled in Comp 412 at Rice

More information

Shenandoah: An ultra-low pause time garbage collector for OpenJDK. Christine Flood Principal Software Engineer Red Hat

Shenandoah: An ultra-low pause time garbage collector for OpenJDK. Christine Flood Principal Software Engineer Red Hat Shenandoah: An ultra-low pause time garbage collector for OpenJDK Christine Flood Principal Software Engineer Red Hat 1 Why do we need another Garbage Collector? OpenJDK currently has: SerialGC ParallelGC

More information

Lecture 2: Memory in C

Lecture 2: Memory in C CIS 330:! / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 2:

More information

CA341 - Comparative Programming Languages

CA341 - Comparative Programming Languages CA341 - Comparative Programming Languages David Sinclair Dynamic Data Structures Generally we do not know how much data a program will have to process. There are 2 ways to handle this: Create a fixed data

More information

Manual Allocation. CS 1622: Garbage Collection. Example 1. Memory Leaks. Example 3. Example 2 11/26/2012. Jonathan Misurda

Manual Allocation. CS 1622: Garbage Collection. Example 1. Memory Leaks. Example 3. Example 2 11/26/2012. Jonathan Misurda Manual llocation Dynamic memory allocation is an obvious necessity in a programming environment. S 1622: Garbage ollection Many programming languages expose some functions or keywords to manage runtime

More information

Review. Partitioning: Divide heap, use different strategies per heap Generational GC: Partition by age Most objects die young

Review. Partitioning: Divide heap, use different strategies per heap Generational GC: Partition by age Most objects die young Generational GC 1 Review Partitioning: Divide heap, use different strategies per heap Generational GC: Partition by age Most objects die young 2 Single-partition scanning Stack Heap Partition #1 Partition

More information

CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11

CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11 CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11 CS 536 Spring 2015 1 Handling Overloaded Declarations Two approaches are popular: 1. Create a single symbol table

More information

Dynamic Memory Alloca/on: Basic Concepts

Dynamic Memory Alloca/on: Basic Concepts Dynamic Memory Alloca/on: Basic Concepts Fall 2015 Instructor: James Griffioen Adapted from slides by R. Bryant and D. O Hallaron (hip://csapp.cs.cmu.edu/public/instructors.html) 1 Today Basic concepts

More information

Dynamic Selection of Application-Specific Garbage Collectors

Dynamic Selection of Application-Specific Garbage Collectors Dynamic Selection of Application-Specific Garbage Collectors Sunil V. Soman Chandra Krintz University of California, Santa Barbara David F. Bacon IBM T.J. Watson Research Center Background VMs/managed

More information

Algorithms for Dynamic Memory Management (236780) Lecture 4. Lecturer: Erez Petrank

Algorithms for Dynamic Memory Management (236780) Lecture 4. Lecturer: Erez Petrank Algorithms for Dynamic Memory Management (236780) Lecture 4 Lecturer: Erez Petrank!1 March 24, 2014 Topics last week The Copying Garbage Collector algorithm: Basics Cheney s collector Additional issues:

More information

Compilers. 8. Run-time Support. Laszlo Böszörmenyi Compilers Run-time - 1

Compilers. 8. Run-time Support. Laszlo Böszörmenyi Compilers Run-time - 1 Compilers 8. Run-time Support Laszlo Böszörmenyi Compilers Run-time - 1 Run-Time Environment A compiler needs an abstract model of the runtime environment of the compiled code It must generate code for

More information

Memory. don t forget to take out the

Memory. don t forget to take out the Memory don t forget to take out the garbage find me on twitter find me on twitter content warnings cw: large animation https://flic.kr/p/vdfhkw the programmer never needs to worry about deallocation

More information

Advanced Programming & C++ Language

Advanced Programming & C++ Language Advanced Programming & C++ Language ~6~ Introduction to Memory Management Ariel University 2018 Dr. Miri (Kopel) Ben-Nissan Stack & Heap 2 The memory a program uses is typically divided into four different

More information

Tick: Concurrent GC in Apache Harmony

Tick: Concurrent GC in Apache Harmony Tick: Concurrent GC in Apache Harmony Xiao-Feng Li 2009-4-12 Acknowledgement: Yunan He, Simon Zhou Agenda Concurrent GC phases and transition Concurrent marking scheduling Concurrent GC algorithms Tick

More information

Mark-Sweep and Mark-Compact GC

Mark-Sweep and Mark-Compact GC Mark-Sweep and Mark-Compact GC Richard Jones Anthony Hoskins Eliot Moss Presented by Pavel Brodsky 04/11/14 Our topics today Two basic garbage collection paradigms: Mark-Sweep GC Mark-Compact GC Definitions

More information

A.Arpaci-Dusseau. Mapping from logical address space to physical address space. CS 537:Operating Systems lecture12.fm.2

A.Arpaci-Dusseau. Mapping from logical address space to physical address space. CS 537:Operating Systems lecture12.fm.2 UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 537 A. Arpaci-Dusseau Intro to Operating Systems Spring 2000 Dynamic Memory Allocation Questions answered in these notes When is a stack

More information

CS2210: Compiler Construction. Runtime Environment

CS2210: Compiler Construction. Runtime Environment : The environment in which the program executes in at runtime Includes HW: Main memory, CPU,... Includes OS: Environment variables,... Includes Runtime Libraries: C Runtime Library (libc),... When a program

More information

CSE 413 Midterm, May 6, 2011 Sample Solution Page 1 of 8

CSE 413 Midterm, May 6, 2011 Sample Solution Page 1 of 8 Question 1. (12 points) For each of the following, what value is printed? (Assume that each group of statements is executed independently in a newly reset Scheme environment.) (a) (define x 1) (define

More information

Dynamic Storage Allocation

Dynamic Storage Allocation 6.172 Performance Engineering of Software Systems LECTURE 10 Dynamic Storage Allocation Charles E. Leiserson October 12, 2010 2010 Charles E. Leiserson 1 Stack Allocation Array and pointer A un Allocate

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 7 More Memory Management CS 61C L07 More Memory Management (1) 2004-09-15 Lecturer PSOE Dan Garcia www.cs.berkeley.edu/~ddgarcia Star Wars

More information

Lecture 13: Complex Types and Garbage Collection

Lecture 13: Complex Types and Garbage Collection Lecture 13: Complex Types and Garbage Collection COMP 524 Programming Language Concepts Stephen Olivier March 17, 2009 Based on slides by A. Block, notes by N. Fisher, F. Hernandez-Campos, and D. Stotts

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 7 C Memory Management 2007-02-06 Hello to Said S. from Columbus, OH CS61C L07 More Memory Management (1) Lecturer SOE Dan Garcia www.cs.berkeley.edu/~ddgarcia

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 7 C Memory Management!!Lecturer SOE Dan Garcia!!!www.cs.berkeley.edu/~ddgarcia CS61C L07 More Memory Management (1)! 2010-02-03! Flexible

More information

A Platform for Research into Object-Level Trace Generation

A Platform for Research into Object-Level Trace Generation A Platform for Research into Object-Level Trace Generation by James Foucar B.S., Computer Science, University of Texas at Austin, 2003 THESIS Submitted in Partial Fulfillment of the Requirements for the

More information

6.172 Performance Engineering of Software Systems Spring Lecture 9. P after. Figure 1: A diagram of the stack (Image by MIT OpenCourseWare.

6.172 Performance Engineering of Software Systems Spring Lecture 9. P after. Figure 1: A diagram of the stack (Image by MIT OpenCourseWare. 6.172 Performance Engineering of Software Systems Spring 2009 Lecture 9 MIT OpenCourseWare Dynamic Storage Allocation Stack allocation: LIFO (last-in-first-out) Array and pointer A used unused P before

More information

Java & Coherence Simon Cook - Sales Consultant, FMW for Financial Services

Java & Coherence Simon Cook - Sales Consultant, FMW for Financial Services Java & Coherence Simon Cook - Sales Consultant, FMW for Financial Services with help from Adrian Nakon - CMC Markets & Andrew Wilson - RBS 1 Coherence Special Interest Group Meeting 1 st March 2012 Presentation

More information

Lecture 7 More Memory Management Slab Allocator. Slab Allocator

Lecture 7 More Memory Management Slab Allocator. Slab Allocator CS61C L07 More Memory Management (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 7 More Memory Management 2006-09-13 Lecturer SOE Dan Garcia www.cs.berkeley.edu/~ddgarcia Unbox problems

More information

Habanero Extreme Scale Software Research Project

Habanero Extreme Scale Software Research Project Habanero Extreme Scale Software Research Project Comp215: Garbage Collection Zoran Budimlić (Rice University) Adapted from Keith Cooper s 2014 lecture in COMP 215. Garbage Collection In Beverly Hills...

More information

the gamedesigninitiative at cornell university Lecture 9 Memory Management

the gamedesigninitiative at cornell university Lecture 9 Memory Management Lecture 9 Gaming Memory Constraints Redux Wii-U Playstation 4 2GB of RAM 1GB dedicated to OS Shared with GPGPU 8GB of RAM Shared GPU, 8-core CPU OS footprint unknown 2 Two Main Concerns with Memory Getting

More information

CS61, Fall 2012 Section 2 Notes

CS61, Fall 2012 Section 2 Notes CS61, Fall 2012 Section 2 Notes (Week of 9/24-9/28) 0. Get source code for section [optional] 1: Variable Duration 2: Memory Errors Common Errors with memory and pointers Valgrind + GDB Common Memory Errors

More information

Effec%ve So*ware. Lecture 9: JVM - Memory Analysis, Data Structures, Object Alloca=on. David Šišlák

Effec%ve So*ware. Lecture 9: JVM - Memory Analysis, Data Structures, Object Alloca=on. David Šišlák Effec%ve So*ware Lecture 9: JVM - Memory Analysis, Data Structures, Object Alloca=on David Šišlák david.sislak@fel.cvut.cz JVM Performance Factors and Memory Analysis» applica=on performance factors total

More information

Glacier: A Garbage Collection Simulation System

Glacier: A Garbage Collection Simulation System Glacier: A Garbage Collection Simulation System Bruno Dufour Sable Research Group McGill University Glacier: A Garbage Collection Simulation System p.1/19 Outline Introduction Objectives & motivation Requirements

More information

Structure of Programming Languages Lecture 10

Structure of Programming Languages Lecture 10 Structure of Programming Languages Lecture 10 CS 6636 4536 Spring 2017 CS 6636 4536 Lecture 10: Classes... 1/23 Spring 2017 1 / 23 Outline 1 1. Types Type Coercion and Conversion Type Classes, Generics,

More information

Memory management has always involved tradeoffs between numerous optimization possibilities: Schemes to manage problem fall into roughly two camps

Memory management has always involved tradeoffs between numerous optimization possibilities: Schemes to manage problem fall into roughly two camps Garbage Collection Garbage collection makes memory management easier for programmers by automatically reclaiming unused memory. The garbage collector in the CLR makes tradeoffs to assure reasonable performance

More information

Lecture Conservative Garbage Collection. 3.2 Precise Garbage Collectors. 3.3 Other Garbage Collection Techniques

Lecture Conservative Garbage Collection. 3.2 Precise Garbage Collectors. 3.3 Other Garbage Collection Techniques CMPSCI 691ST Systems Fall 2011 Lecture 3 Lecturer: Emery Berger Scribe: Nicolas Scarrci 3.1 Conservative Garbage Collection The Boehm collector is the first example of conservative garbage collection.

More information

CS577 Modern Language Processors. Spring 2018 Lecture Garbage Collection

CS577 Modern Language Processors. Spring 2018 Lecture Garbage Collection CS577 Modern Language Processors Spring 2018 Lecture Garbage Collection 1 BASIC GARBAGE COLLECTION Garbage Collection (GC) is the automatic reclamation of heap records that will never again be accessed

More information

Lecture 7: Binding Time and Storage

Lecture 7: Binding Time and Storage Lecture 7: Binding Time and Storage COMP 524 Programming Language Concepts Stephen Olivier February 5, 2009 Based on notes by A. Block, N. Fisher, F. Hernandez-Campos, and D. Stotts Goal of Lecture The

More information

Memory Management: The Details

Memory Management: The Details Lecture 10 Memory Management: The Details Sizing Up Memory Primitive Data Types Complex Data Types byte: char: short: basic value (8 bits) 1 byte 2 bytes Pointer: platform dependent 4 bytes on 32 bit machine

More information