Bounding Space Usage of Conservative Garbage Collectors Ohad Shacham December 2002 Based on work by Hans-J. Boehm.

Slides:



Advertisements
Similar presentations
An Implementation of Mostly- Copying GC on Ruby VM Tomoharu Ugawa The University of Electro-Communications, Japan.
Advertisements

Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Garbage collection David Walker CS 320. Where are we? Last time: A survey of common garbage collection techniques –Manual memory management –Reference.
Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
(Chapter 5) Deleting Objects
Automatic Memory Management Noam Rinetzky Schreiber 123A /seminar/seminar1415a.html.
Context-Sensitive Interprocedural Points-to Analysis in the Presence of Function Pointers Presentation by Patrick Kaleem Justin.
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
1 Greedy Forwarding in Dynamic Scale-Free Networks Embedded in Hyperbolic Metric Spaces Dmitri Krioukov CAIDA/UCSD Joint work with F. Papadopoulos, M.
Space Efficient Conservative Garbage Collection Hans-Juergen Boehm, Xerox PARC Presented by Ryan Braud.
Lecture 10: Heap Management CS 540 GMU Spring 2009.
Garbage Collection What is garbage and how can we deal with it?
5. Memory Management From: Chapter 5, Modern Compiler Design, by Dick Grunt et al.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
Mark and Sweep Algorithm Reference Counting Memory Related PitFalls
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.
Garbage Collection Mooly Sagiv html://
Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.
Memory Allocation. Three kinds of memory Fixed memory Stack memory Heap memory.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
Run time vs. Compile time
Memory Allocation and Garbage Collection. Why Dynamic Memory? We cannot know memory requirements in advance when the program is written. We cannot know.
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
Linked lists and memory allocation Prof. Noah Snavely CS1114
Chapter 3: Arrays, Linked Lists, and Recursion
Student Seminar – Fall 2012 A Simple Algorithm for Finding Frequent Elements in Streams and Bags RICHARD M. KARP, SCOTT SHENKER and CHRISTOS H. PAPADIMITRIOU.
1/25 Pointer Logic Changki PSWLAB Pointer Logic Daniel Kroening and Ofer Strichman Decision Procedure.
Storage Management. The stack and the heap Dynamic storage allocation refers to allocating space for variables at run time Most modern languages support.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
1 Records Record aggregate of data elements –Possibly heterogeneous –Elements/slots are identified by names –Elements in same fixed order in all records.
1 Lecture 22 Garbage Collection Mark and Sweep, Stop and Copy, Reference Counting Ras Bodik Shaon Barman Thibaud Hottelier Hack Your Language! CS164: Introduction.
11/26/2015IT 3271 Memory Management (Ch 14) n Dynamic memory allocation Language systems provide an important hidden player: Runtime memory manager – Activation.
Simple Classes. ADTs A specification for a real world data item –defines types and valid ranges –defines valid operations on the data. Specification is.
Linked List by Chapter 5 Linked List by
Garbage Collection and Memory Management CS 480/680 – Comparative Languages.
ISBN Chapter 6 Data Types Pointer Types Reference Types Memory Management.
More Distributed Garbage Collection DC4 Reference Listing Distributed Mark and Sweep Tracing in Groups.
© 2004 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice Minimally Conservative Garbage Collection.
GARBAGE COLLECTION IN AN UNCOOPERATIVE ENVIRONMENT Hans-Juergen Boehm Computer Science Dept. Rice University, Houston Mark Wieser Xerox Corporation, Palo.
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.
Heaps and basic data structures David Kauchak cs161 Summer 2009.
Chapter 5 Linked List by Before you learn Linked List 3 rd level of Data Structures Intermediate Level of Understanding for C++ Please.
2/4/20161 GC16/3011 Functional Programming Lecture 20 Garbage Collection Techniques.
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
CS412/413 Introduction to Compilers and Translators April 21, 1999 Lecture 30: Garbage collection.
Chapter - 2 Data strucuters for Language processing.
Naming CSCI 6900/4900. Unreferenced Objects in Dist. Systems Objects no longer needed as nobody has a reference to them and hence will not use them Garbage.
Sections Basic Data Structures. 1.5 Data Structures The way you view and structure the data that your programs manipulate greatly influences your.
List data structure This is a new data structure. The List data structure is among the most generic of data structures. In daily life, we use shopping.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Garbage Collection What is garbage and how can we deal with it?
Data Types In Text: Chapter 6.
Lecture 6 of Computer Science II
Module 9: Memory and Resource Management
Data Structure Interview Question and Answers
Seminar in automatic tools for analyzing programs with dynamic memory
Storage Management.
Data Structures Interview / VIVA Questions and Answers
Concepts of programming languages
Automatic Memory Management/GC
Automatic Memory Management
Arrays and Linked Lists
Lesson Objectives Aims
Strategies for automatic memory management
Linked Lists.
Created By: Asst. Prof. Ashish Shah, J.M.Patel College, Goregoan West
Data Structures & Algorithms
Garbage Collection What is garbage and how can we deal with it?
Presentation transcript:

Bounding Space Usage of Conservative Garbage Collectors Ohad Shacham December 2002 Based on work by Hans-J. Boehm

Garbage Collector Mechanism that allows automatic recycling of unreachable memory objects Convenience – the programmer does not need to deallocate memory. Safety – don’t reuse reachable memory objects

Conservative GC Garbage collector that tolerates ambiguous pointers Ambiguous pointer – location which may or may not be a pointer CGC treated ambiguous pointer whose value is valid object address as they were pointers

Why do we use CGC? C/C++ programs Compilers that generate C code Compiler/Collector interface can be much simpler Facilitate language interoperability Etc…

CGC Problems Can’t safely update a pointer to a moved object (unless we are sure that the pointer is unambiguous) Bad for programs with a large number of very short lived objects Retaining unreferenced memory as a result of misidentified pointers Integer that misidentified as a pointer to a large Data Structure

Embarrassing Failure Scenario headtail

Embarrassing Failure Scenario headtail

Embarrassing Failure Scenario headtail

Embarrassing Failure Scenario headtail

Embarrassing Failure Scenario headtail

Embarrassing Failure Scenario headtail

Embarrassing Failure Scenario headtail

Embarrassing Failure Scenario headtail - - False Reference Unbounded space retaining How can it be fixed? Assigning NULL to the next field in the list element being removed from the queue

Our Purpose We know that conservatively collected programs can retain large amount of memory due to a particularly misidentified pointer We want to bound space usage independently of the particular misidentified pointers that arise during a particular execution

Motivation Provide intuitive explanations why CGC behaves reasonably well in practice Provide better characteristic of what can provoke failure of CGC Make CGC safe for environments that required hard space bound

How we’ll satisfy our motivation? Prove mathematical bound on space consumption Suggest a testing technique for identifying potential unbounded growth without executing the program and identifying misidentified pointers

Reachability Reachable Object – An object that can be reached by a real pointer (Y) Backward Reachable Objects – A set of Objects that are backward reachable from a real pointer {Y,Z,L,K} XY - - root Y L K Z X - - root D

Backward Forward Reachability Backward Forward Reachable Object – An object that is reachable through an anchor X and X is backward reachable (Y) X Y root

Strongly GC Robust Data Structure is Strongly GC robust iff all objects that are backward forward reachable from a root through a single anchor were at some point reachable through a root

Who doesn’t satisfy Strongly GC Robust criterion? Our FIFO queue example head tail headtail But these objects weren’t reachable at the same time head

Who does satisfy Strongly GC Robust criterion? Purely functional programs e.g. Stack head

Bounding the Space Consumption Set of Objects S that is reachable from an unreachable object x, were at some point backward forward reachable through object x X root

So what do we know? Set of Objects S that is reachable from an unreachable object x, was at some point backward forward reachable through object x Objects that are backward forward reachable in Strongly GC robust Data Structures were at some point reachable In programs that use only Strongly GC robust DS A Set of objects S that is reachable from an unreachable Object x was at some point reachable

Bounding the Space Consumption If a program uses only Strongly GC robust DS and the number of misidentified pointers in bounded by N, then the extra space retaining by CGC is bounded by N * maximal amount of live memory

What did we want to Satisfy? Prove mathematical bound on space consumption Suggest a testing technique for identifying potential unbounded growth without executing the program and identifying misidentified pointers

Observation The number of reachable objects from an unreachable object x that are not reachable from a proper root grows only if some objects became unreachable from a proper roots.

Observation X Reachable Objects Unreachable Objects Proper Roots

Observation X Reachable Objects Unreachable Objects Proper Roots False Reference

Theorem If the number of objects reachable from an unreachable object x but not reachable from proper roots grows without bound, then the length of the longest simple path from x through unreachable objects to a reachable object also grow without bounds

Proof According to our observation a path to a reachable object can grow only if a reachable object became unreachable We have two cases: 1. The newly unreachable object is on a path to a reachable object 2. The newly unreachable object is not on a path to a reachable object

Proof 1. We have two cases 1. The object is on a simple path 2. The object is not on a simple path False Referencex y w

So What do we know? Number of objects reachable from x but unreachable From proper roots grows without bound the length of the longest simple path From x through unreachable objects to a reachable object grows without bound

Therefore Number of objects reachable from x but unreachable From proper roots grows with bound the length of the longest simple path From x through unreachable objects to a reachable object grows with bound

Weakly GC Robust A Data Structure is weakly GC robust if the length of simple paths through unreachable objects ending at an object in the Data Structure remains bounded for any execution

Who does satisfy Weakly GC Robust ? Our FIFO queue with restriction that only bounded number of objects are ever removed headtail - - Bounded False Reference

Who doesn’t satisfy Weakly GC Robust ? Our FIFO queue without the previous restriction headtail - - Unbounded False Reference

Strongly VS Weakly Strongly Precise bound on the cost of misidentification pointer Max (live memory) Weakly Reason about bonded Vs unbounded space loss

Testing Algorithm 1. Building a backward reachability graph 2. Marking all the reachable objects 3. Performing DFS on the graph from 1 and counting the height of each reachable object. Reporting the maximum height 4. Attach to each reachable object its height 5. Discard unreachable objects and the auxiliary DS from 1

Stage 1 a c g i b f e n k d h l j m a b c d e f g j h i l n k m

Stage 2 a c g i b f e n k d h l j m a b c d e f g j h i l n k m

Stage 3 a c g i b f e n k d h l j m a b c d e f g j h i l n k m

Stage 4 a c g i b f e n k d h l j m a b c d e f g j h i l n k m

Stage 5 a g f n k j m 4 3

Results In most of the tests the maximum counter stabilized in tens or hundreds In our FIFO queue the counter passed the million

Conclusions In Strongly GC robust DS the space retaining is bounded by the maximum of live memory for each misidentified pointer Conjecture – All the DS, except for the straightforward implementation of a singly linked queue and infinite data structure that relay on lazy evaluation are weakly GC robust