Review. Partitioning: Divide heap, use different strategies per heap Generational GC: Partition by age Most objects die young
|
|
- Sabrina Armstrong
- 5 years ago
- Views:
Transcription
1 Generational GC 1
2 Review Partitioning: Divide heap, use different strategies per heap Generational GC: Partition by age Most objects die young 2
3 Single-partition scanning Stack Heap Partition #1 Partition #2 3
4 Single-partition scanning Stack Heap Partition #1 Partition #2 Don t follow pointers out of partition: Not our job 3
5 Single-partition scanning Stack Heap Partition #1 Partition #2 Don t follow pointers out of partition: Not our job Our partition s objects could be referenced by other partitions 3
6 Single-partition scanning Stack Heap Partition #1 Partition #2 4
7 Single-partition scanning Stack Heap Partition #1 Partition #2 Cannot be collected! 4
8 Alternate approach Stack Heap Partition #1 Partition #2 Pseudoroot 5
9 The big idea Most objects die young Partition heap by age Nursery partition collected frequently Old partition only collected during fullheap GC 6
10 Inter-partition references Never collect old partition without young Only need to remember old young interpartition references Write barrier is back! (Details later) Treat old objects w/ young refs as roots 7
11 Generational GC Stack Nursery Heap Old generation 8
12 Generational GC Stack Nursery Heap Old generation No need to specially mark this reference 8
13 Generational GC Stack Nursery Heap Old generation No need to specially mark this reference Need to remember this reference when doing young GC 8
14 Promotion Stack Nursery Heap Old generation 9
15 Promotion Stack Nursery Heap Old generation 9
16 Promotion Stack Nursery Heap Old generation 9
17 En masse generational When nursery is full, collect nursery Copying GC, treat old generation as tospace Old gen can have any allocator After GC, nursery is empty by definition When old generation is full, full collect 10
18 When to GC Allocation in old generation only done by young GC GC of old generation only done due to allocation in old generation Therefore: Full collection caused by partial young collection 11
19 Weird promotions Old generation is full, GC everything Cannot now promote: Old gen is full! Nursery in half-collected state, but can t continue copying 12
20 Solution: No worries! Update references to already-copied objects Scan but don t copy newly-found young objects When finished with full collection, collect young again Careful for collection loops! 13
21 En-masse advantages Copying without semispaces: No wasted heap Young collection very fast Young-death objects don t impact performance 14
22 GC timeline Time O1 O2 alloc alloc O3 alloc O1 dies O4 alloc GC O2 dies O5 alloc O3 dies O6 alloc 15
23 GC timeline Time O1 O2 alloc alloc O3 alloc O1 dies O4 alloc GC O2 dies O5 alloc O3 dies O6 alloc Wrongly promoted, will take a long time to collect! 15
24 Tempered generational GC Don t promote objects on first GC Decide whether to promote from age Leave very young objects in nursery 16
25 Determining age Wall clock: Easy: Put time in header, check it Problem: Machine- and program-dependent, young for one app may be old for other Memory age (words allocated since): Robust to app differences Difficult/impossible to implement 17
26 Determining age Collection count: Every time object survives collection, collection count +1 Approximates memory age Easy to track: Add counter to header 18
27 Collection counter Stack Nursery tospace 0 0 fromspace 1 Heap Old generation 19
28 Collection counter Stack Nursery fromspace Heap Old generation tospace
29 Collection counter Stack Nursery tospace 2 2 Heap Old generation fromspace 21
30 Collection counter Stack Nursery tospace 2 2 Heap Old generation fromspace Created inter-generational link during GC! 21
31 Collection counter Stack Nursery tospace 2 2 Heap Old generation With young gen copying, still need semispace: Wasted heap fromspace Created inter-generational link during GC! 21
32 Collection counter Semispace problems are back: Waste half of young space Not all objects promoted: Can create intergenerational links 22
33 The bucket brigade Alloc GC GC 0 1 Old Nursery Old generation 23
34 The broken bucket brigade Alloc GC GC fromspace tospace 0 Nursery Old generation 24
35 Bucket brigade Copy objects from bucket n to bucket n+1 Cannot just use semispace copying with from=0, to=1: tospace already partially used Emptied tospace prefix not available 25
36 The Java bucket brigade Alloc GC GC fromspace 0 Old tospace Nursery Old generation 26
37 Java [HotSpot] collection Nursery: Bucket 0 ( Eden ) flat space Bucket 1 ( Survivor ) semi-space copying Old generation mark-and-compact 27
38 Young collection algorithm youngcollect(): (scan roots) b1fromspace, b1tospace := b1tospace, b1fromspace while loc := worklist.pop(): obj := *loc if!obj->header.forward: if obj in bucket 0: obj->header.forward := (copy to b1tospace) else if obj in bucket 1: obj->header.forward := (copy obj to old gen) (add references in newly-copied object) *loc := obj->header.forward 28
39 Overhead But still wasting heap for semispaces! Most objects die young: Even by bucket 1, most objects dead Remember: You allocate pools, so you choose heap, generation, bucket sizes! Typically, bucket 0 32x larger than one space in bucket 1 29
40 Caveat Of course, bucket 0 could fill b1tospace Expand b1 spaces during collection: Want H=n*L (all objects copied in are in L) Can t expand more? Fallback to copying to old gen 30
41 Breather Alloc GC GC fromspace 0 Old tospace Nursery Old generation 31
42 Write barrier To collect just nursery, remember objects in old generation which have inter-generation references In practice: Over-approximate Treat portions of old generation as roots for nursery collection 32
43 Remembered set Remember a portion of old generation as interesting During young GC, scan objects in remembered set During full GC, clear remembered set 33
44 Cards Typical (read: Java) GCs use cards Divide pools into smaller chunks called cards of power-of-2 size Remembered set is bit-array of size #-ofcards-per-pool To remember a card, mark its bit 34
45 Card barrier write(obj, loc, val): if genof(obj) == old and genof(val) == young: poolof(obj)->remember[cardof(obj)] := 1 *loc = val poolof(ptr): ptr & POOL_MASK cardof(ptr): (ptr & ~POOL_MASK) >> CARD_SIZE_POW2 35
46 Card use During young GC, scan each old pool s remembered set For each 1, scan objects in corresponding card Note: Cards must be parsable! 36
47 Parsable cards Objects may span cards To parse card, need to know offset of first object in card Additional element in pool: Offsets of first objects within cards 37
48 Parsable cards oldallocate(): bump-pointer : ret := end end += size if cardof(obj)!= cardof(end): pool->firstobjs[cardof(end)] := offsetincard(end) split free-list : if cardof(ret)!= cardof(split): pool->firstobjs[cardof(split)] := offsetincard(split) 38
49 Summary Young gen in buckets, promoted to old gen from oldest bucket Oldest bucket semispace Pointers from old gen remembered by cards Cards treated like roots (but scanned as objects) 39
50 Cards (part deux) 40
51 Cards Partitioned (e.g. generational) GC must remember certain inter-partition refs Remembering each object too expensive Divide generation into cards 41
52 Pools with cards struct Pool { struct Pool *next; struct FreeObject *freeobjects; void *freespace; char remember[cards_per_pool]; unsigned short firstobjs [CARDS_PER_POOL]; }; 42
53 Allocation with cards Remember: firstobjs there to make cards parsable Need to worry about firstobjs Matters during: Bump-pointer allocation Free-list allocation splitting Coalescence 43
54 Parsing cards scancard(pool, cardno): loc := pool + cardno*card_size + pool->firstobj[cardno] while cardof(loc) == cardno: obj := loc (scan this object) loc += obj->header.size 44
55 youngcollect(): (add roots to worklist) (add remembered set to worklist) fromspace, tospace := tospace, fromspace while loc := worklist.pop() obj := *loc if obj is young and!obj->header.forward: if obj->header.collectioncount < 1: (move obj to newobj in tospace) obj->header.collectioncount++ obj->header.forward = newobj else: newobj := (try old gen allocator) if newobj == NULL: collectfull() (retry young collection) obj->header.forward = newobj (scan newobj) if obj->header.forward: *loc := obj->header.forward 45
56 youngcollect(): (add roots to worklist) Using e.g. scancard (add remembered set to worklist) fromspace, tospace := tospace, fromspace while loc := worklist.pop() obj := *loc if obj is young and!obj->header.forward: if obj->header.collectioncount < 1: (move obj to newobj in tospace) obj->header.collectioncount++ obj->header.forward = newobj else: newobj := (try old gen allocator) if newobj == NULL: collectfull() (retry young collection) obj->header.forward = newobj (scan newobj) if obj->header.forward: *loc := obj->header.forward 45
57 youngcollect(): (add roots to worklist) Using e.g. scancard (add remembered set to worklist) fromspace, tospace := tospace, fromspace while loc := worklist.pop() Ignore old objects obj := *loc if obj is young and!obj->header.forward: if obj->header.collectioncount < 1: (move obj to newobj in tospace) obj->header.collectioncount++ obj->header.forward = newobj else: newobj := (try old gen allocator) if newobj == NULL: collectfull() (retry young collection) obj->header.forward = newobj (scan newobj) if obj->header.forward: *loc := obj->header.forward 45
58 youngcollect(): (add roots to worklist) (add remembered set to worklist) fromspace, tospace := tospace, fromspace while loc := worklist.pop() obj := *loc if obj is young and!obj->header.forward: if obj->header.collectioncount < 1: (move obj to newobj in tospace) obj->header.collectioncount++ obj->header.forward = newobj else: newobj := (try old gen allocator) if newobj == NULL: collectfull() (retry young collection) obj->header.forward = newobj (scan newobj) if obj->header.forward: *loc := obj->header.forward Using e.g. scancard Ignore old objects Remember: This could have created inter-partition references! 45
59 Runtime interface 46
60 Review Unreachable objects dead Sweep, copying, compacting, ref counting Combine with partitioning, generational Most objects die young, so partitioning by age universal Also useful to partition large objects, threads, executable objects, etc 47
61 Runtime interface Compiler, memory manager and (possibly) programmer must agree Compiler motivated by language, so memory manager often motivated by language too GGGGC s interface is simple by design 48
62 Runtime interface Important components: Allocation Where references are in roots, objects When collection can occur Barriers on writing to (reading from?) objects 49
63 Allocation 50
64 Allocation C malloc Just give me some bytes. Memory manager needs no type info. Object returned full of garbage. 50
65 Allocation C malloc Just give me some bytes. Memory manager needs no type info. Haskell allocation I promise not to touch! Memory manager knows all! Object returned full of garbage. Object returned fully initialized, immutable. 50
66 Allocation C malloc Just give me some bytes. Memory manager needs no type info. Java new Good enough is good enough. Memory manager needs refs. Haskell allocation I promise not to touch! Memory manager knows all! Object returned full of garbage. Object returned full of zeroes. Object returned fully initialized, immutable. 50
67 Allocation and initialization Time Allocation Initialization Use 51
68 Allocation and initialization Time C Allocation Initialization Use Manager Mutator Java Haskell Manager Manager Mutator Mutator 51
69 Constructor problem GC depends on correct objects Correct for us means: References refer to valid objects or NULL If an object scanned mid-initialization, it may not be correct! Options: Prevent GC mid-initialization, or initialize ourselves 52
70 Mid-initialization GC If initialization cannot allocate objects, we could prevent collection Does not generalize Initialization often not guaranteed correct anyway (just user code) Generally, manager must initialize 53
71 Zeroing Simple initialization: All bits zero Mundane value for virtually all types Simple initialization for manager Consequence: Objects initialized twice! (Once by manager, once by program) 54
72 When to zero 55
73 When to zero During allocation Makes allocation slower. Inefficient to spread work over many allocations. 55
74 When to zero During allocation Makes allocation slower. Inefficient to spread work over many allocations. During collection Makes collection (much!) slower. Impossible with freelist. Efficient. 55
75 When to zero During allocation Ahead of allocation During collection Makes allocation slower. Inefficient to spread work over many allocations. Zero chunks beyond current object during allocation. Choose chunk size wisely (cache line or page) for efficiency. Makes collection (much!) slower. Impossible with freelist. Efficient. 55
76 Runtime interface Important components: Allocation Where references are in roots, objects When collection can occur Barriers on writing to (reading from?) objects 56
77 How to identify references 57
78 How to identify references Conservative If it looks like it might be a reference, it s a reference. 57
79 How to identify references Conservative If it looks like it might be a reference, it s a reference. Precise Compiler must know location of all references and tell the GC. Usual for staticallytyped languages. 57
80 How to identify references Conservative If it looks like it might be a reference, it s a reference. Tagged References stored differently from data. Known only at runtime. Precise Compiler must know location of all references and tell the GC. Usual for dynamically-typed languages. Usual for staticallytyped languages. 57
81 Tagged references function FancyString(x) { return "\"" + x.tostring() + "\""; } This code works whether x is a reference or not (That s JavaScript!) 58
82 Refresher: Bit-sneakiness There are three 1 wasted bits in our header Pool address Object address Always 0! All pointers have this extra space! 1 On 32-bit systems, two 59
83 Tagged references Use extra bits as type e.g.: References end in 000, Integers end in 1, Strings end in 010, Compiler and GC must agree Compiler must untag values to use them 60
84 Tagged references trace(obj): for loc in obj to obj + (size) if (*loc & 0b111) == 0: trace(*loc) 61
85 Precise object references You ve seen plenty of this! Bitmaps is pretty much how it s done In some (usually functional) language, object type includes trace function: Compiler creates trace function per type GC calls trace function referred to in descriptor 62
86 Stack references Pointer stacks (ala GGGGC) is not the most common choice Options: Secondary reference stack Parsable stack Heap-allocated stack Object-shaped stack 63
87 Secondary reference stack Normal stack has no references, second stack has only references C stack Ref stack 64
88 Secondary reference stack Normal stack has no references, second stack has only references foo foo C stack Ref stack foo() 64
89 Secondary reference stack Normal stack has no references, second stack has only references foo foo foo() bar bar bar() C stack Ref stack 64
90 Secondary reference stack Normal stack has no references, second stack has only references foo bar baf C stack foo bar baf Ref stack foo() bar() baf() 64
91 Secondary reference stack Normal stack has no references, second stack has only references foo bar baf C stack foo bar baf Ref stack foo() bar() baf() GC scans only this stack Simply read entire stack: There are only references 64
92 Reference stack caveats Usually needs reference stack register CPU registers are rare! Complicates other parts of compiler, e.g. exception handling 65
93 Parsable stack Like parsable heap: Make sure GC can find info in stack C stack 66
94 Parsable stack Like parsable heap: Make sure GC can find info in stack foo foo() h C stack 66
95 Parsable stack Like parsable heap: Make sure GC can find info in stack foo h bar h C stack foo() bar() 66
96 Parsable stack Like parsable heap: Make sure GC can find info in stack foo h bar h baf h C stack foo() bar() baf() 66
97 Parsable stack caveats Does not play nicely with others (C, C++) 67
98 Heap-allocated stack Every function allocates a stack object, chains those together into pseudo-stack Root Heap 68
99 Heap-allocated stack Every function allocates a stack object, chains those together into pseudo-stack Root Heap foo foo() 68
100 Heap-allocated stack Every function allocates a stack object, chains those together into pseudo-stack Root Heap foo bar foo() bar() 68
101 Heap-allocated stack Every function allocates a stack object, chains those together into pseudo-stack Root Heap baf foo bar foo() bar() baf() 68
102 Heap-allocated stack caveats Stack frames outlive function execution Easy closures! Need descriptors for every possible stack frame Restrictive to compiler 69
103 Object-shaped stack Exactly like heap-allocated stack, but allocate stack frame objects on stack Caveat: GC must expect objects in stack Stack is now a partition 70
104 What is a reference? Thusfar: Reference is pointer to beginning of object Possibilities to consider: Interior pointers Indirect pointers 71
105 Interior pointer struct List { struct List *next; int val; }; void breakthings(struct List *l) { int *nasty = &l->val; l = l->next; // yield to GC printf("%d\n", *nasty); } 72
106 Interior pointers Usual solution: Not allowed When allowed: 1. Get chunk (e.g. card) associated with interior pointer 2. Parse chunk to find containing object 3. If moving, preserve offset 73
107 Object tables Alternative contract between compiler and memory manager Instead of program using (e.g.) struct List * always use (e.g.) struct List ** 74
108 Object tables Accessing object is double-dereference User pointer refers to object table entry, object table entry refers to object. Object table forms its own partition Object table entries don t move 75
109 Object table thoughts Slows down object access Allows atomic object replacement i.e., one object may replace another Makes moving objects simple (only one ref to update) Makes mark-and-compact require only one sweep! 76
110 Runtime interface Important components: Allocation Where references are in roots, objects When collection can occur Barriers on writing to (reading from?) objects 77
111 Any-time collection Threads may be doing anything at any time Can we stop mutator at any time to collect? Think about stack references: Mutator must never deviate from description Very limiting to optimizations 78
112 Yieldpoint collection Compiler adds yieldpoints to allow collection Between yieldpoints, stack in inconsistent state To stop, wait for all threads to reach yeildpoint 79
113 When to yield Mandatory: During allocation, at function calls Optional: At tight loops or other longrunning operations Threads must yield frequently to allow GC to occur promptly 80
114 How to yield Polling: void yield() { if (stoptheworld) collect(); } Patching: Overwrite the yield function with a version that stops the thread 81
115 Runtime interface Important components: Allocation Where references are in roots, objects When collection can occur Barriers on writing to (reading from?) objects 82
116 Write barriers Either reference counting or inter-partition remembering For inter-partition remembering: Guard (check that ref must be remembered) Remember (e.g. write bit for card) 83
117 Write barrier guard write(obj, loc, val): if genof(obj) == old and genof(val) == young: genof isn t cheap (bit math to get pool, read gen from pool header) 84
118 Arranging for better barriers Sometimes can ask for pools at certain locations in memory Approximate generation check with location check Imperfect guard means more remembered set writing, but less time in write barrier 85
119 Sequential heap guard write(obj, loc, val): if obj > val: Write barrier can trigger improperly, but the check is (usually) one CPU operation Young gen must have (pointless) remembered set 86
120 Unguarded write barrier write(obj, loc, val): poolof(obj)->(remember obj) *loc := val All writes more expensive, remembered set less precise, but write time is predictable. 87
121 Runtime interface Summary: Allocation Where references are in roots, objects When collection can occur Barriers on writing to (reading from?) objects 88
122 Presentations Next week we start presentations [If any presentation doesn t happen, I will blather in the interim] I will have some final words on the last day Make sure to talk to me about your final projects! 89
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 informationAcknowledgements 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 informationAlgorithms 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 informationLecture 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 informationRuntime. 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 informationA 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 informationHeap 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 informationDeallocation 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 informationManaged 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 informationGarbage 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 informationManaged 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 informationCS842: Automatic Memory Management and Garbage Collection. GC basics
CS842: Automatic Memory Management and Garbage Collection GC basics 1 Review Noting mmap (space allocated) Mapped space Wile owned by program, manager as no reference! malloc (object created) Never returned
More informationCMSC 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 informationGarbage 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 informationProgramming 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 informationCMSC 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 informationSustainable 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 informationImplementation 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 informationLecture 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 informationGarbage 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 informationLecture 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 informationCMSC 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 informationCSE P 501 Compilers. Memory Management and Garbage Collec<on Hal Perkins Winter UW CSE P 501 Winter 2016 W-1
CSE P 501 Compilers Memory Management and Garbage Collec
More informationHarmony 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 informationCompiler Construction D7011E
Compiler Construction D7011E Lecture 14: Memory Management Viktor Leijon Slides largely by Johan Nordlander with material generously provided by Mark P. Jones. 1 First: Run-time Systems 2 The Final Component:
More informationCS 31: Intro to Systems Pointers and Memory. Kevin Webb Swarthmore College October 2, 2018
CS 31: Intro to Systems Pointers and Memory Kevin Webb Swarthmore College October 2, 2018 Overview How to reference the location of a variable in memory Where variables are placed in memory How to make
More informationLecture 15 Advanced Garbage Collection
Lecture 15 Advanced Garbage Collection I. Break Up GC in Time (Incremental) II. Break Up GC in Space (Partial) Readings: Ch. 7.6.4-7.7.4 CS243: Advanced Garbage Collection 1 Trace-Based GC: Memory Life-Cycle
More informationGarbage 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 informationCS 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 informationGarbage 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 informationCS577 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 informationCS 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 informationGarbage Collection (2) Advanced Operating Systems Lecture 9
Garbage Collection (2) Advanced Operating Systems Lecture 9 Lecture Outline Garbage collection Generational algorithms Incremental algorithms Real-time garbage collection Practical factors 2 Object Lifetimes
More informationCS 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 informationCS 318 Principles of Operating Systems
CS 318 Principles of Operating Systems Fall 2017 Lecture 16: File Systems Examples Ryan Huang File Systems Examples BSD Fast File System (FFS) - What were the problems with the original Unix FS? - How
More informationRun-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 informationHOT-Compilation: Garbage Collection
HOT-Compilation: Garbage Collection TA: Akiva Leffert aleffert@andrew.cmu.edu Out: Saturday, December 9th In: Tuesday, December 9th (Before midnight) Introduction It s time to take a step back and congratulate
More informationCS61, 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 informationExploiting 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 informationHabanero 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 informationParallel GC. (Chapter 14) Eleanor Ainy December 16 th 2014
GC (Chapter 14) Eleanor Ainy December 16 th 2014 1 Outline of Today s Talk How to use parallelism in each of the 4 components of tracing GC: Marking Copying Sweeping Compaction 2 Introduction Till now
More informationCS 318 Principles of Operating Systems
CS 318 Principles of Operating Systems Fall 2018 Lecture 16: Advanced File Systems Ryan Huang Slides adapted from Andrea Arpaci-Dusseau s lecture 11/6/18 CS 318 Lecture 16 Advanced File Systems 2 11/6/18
More informationMemory 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 informationAdvanced 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 informationHeap Arrays and Linked Lists. Steven R. Bagley
Heap Arrays and Linked Lists Steven R. Bagley Recap Data is stored in variables Can be accessed by the variable name Or in an array, accessed by name and index Variables and arrays have a type Create our
More informationCA341 - 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 informationDesign 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 informationCS 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 informationCS 31: Intro to Systems Pointers and Memory. Martin Gagne Swarthmore College February 16, 2016
CS 31: Intro to Systems Pointers and Memory Martin Gagne Swarthmore College February 16, 2016 So we declared a pointer How do we make it point to something? 1. Assign it the address of an existing variable
More informationCS61C Midterm Review on C & Memory Management
CS61C Midterm Review on C & Memory Management Fall 2006 Aaron Staley Some material taken from slides by: Michael Le Navtej Sadhal Overview C Array and Pointer Goodness! Memory Management The Three Three
More informationDynamic 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 informationShenandoah 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 informationTHE TROUBLE WITH MEMORY
THE TROUBLE WITH MEMORY OUR MARKETING SLIDE Kirk Pepperdine Authors of jpdm, a performance diagnostic model Co-founded Building the smart generation of performance diagnostic tooling Bring predictability
More informationRobust 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 informationAttila Szegedi, Software
Attila Szegedi, Software Engineer @asz Everything I ever learned about JVM performance tuning @twitter Everything More than I ever wanted to learned about JVM performance tuning @twitter Memory tuning
More informationCompilers. 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 informationGarbage 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 informationDynamic Memory Allocation
Dynamic Memory Allocation CS61, Lecture 11 Prof. Stephen Chong October 6, 2011 Announcements 1/2 Reminder: No section on Monday Monday sections have been rescheduled See website for details Please attend
More informationEngine Support System. asyrani.com
Engine Support System asyrani.com A game engine is a complex piece of software consisting of many interacting subsystems. When the engine first starts up, each subsystem must be configured and initialized
More informationReference Counting. Reference counting: a way to know whether a record has other users
Garbage Collection Today: various garbage collection strategies; basic ideas: Allocate until we run out of space; then try to free stuff Invariant: only the PL implementation (runtime system) knows about
More informationGarbage Collection Basics
Garbage Collection Basics 1 Freeing memory is a pain Need to decide on a protocol (who frees what when?) Pollutes interfaces Errors hard to track down Remember 211 / 213?... but lets try an example anyway
More informationMemory 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 informationThe Art and Science of Memory Allocation
Logical Diagram The Art and Science of Memory Allocation Don Porter CSE 506 Binary Formats RCU Memory Management Memory Allocators CPU Scheduler User System Calls Kernel Today s Lecture File System Networking
More informationOne-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 informationCS61C : 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 informationMark-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 informationJava Performance Tuning
443 North Clark St, Suite 350 Chicago, IL 60654 Phone: (312) 229-1727 Java Performance Tuning This white paper presents the basics of Java Performance Tuning and its preferred values for large deployments
More informationThe Generational Hypothesis
Generational GC 1 The Generational Hypothesis Hypothesis: most objects "die young" i.e., they are only needed for a short time, and can be collected soon A great example of empirical systems work Found
More informationMotivation for Dynamic Memory. Dynamic Memory Allocation. Stack Organization. Stack Discussion. Questions answered in this lecture:
CS 537 Introduction to Operating Systems UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department Dynamic Memory Allocation Questions answered in this lecture: When is a stack appropriate? When is
More informationMyths 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 informationGarbage-First Garbage Collection by David Detlefs, Christine Flood, Steve Heller & Tony Printezis. Presented by Edward Raff
Garbage-First Garbage Collection by David Detlefs, Christine Flood, Steve Heller & Tony Printezis Presented by Edward Raff Motivational Setup Java Enterprise World High end multiprocessor servers Large
More informationAgenda. CSE P 501 Compilers. Java Implementation Overview. JVM Architecture. JVM Runtime Data Areas (1) JVM Data Types. CSE P 501 Su04 T-1
Agenda CSE P 501 Compilers Java Implementation JVMs, JITs &c Hal Perkins Summer 2004 Java virtual machine architecture.class files Class loading Execution engines Interpreters & JITs various strategies
More informationProject. there are a couple of 3 person teams. a new drop with new type checking is coming. regroup or see me or forever hold your peace
Project there are a couple of 3 person teams regroup or see me or forever hold your peace a new drop with new type checking is coming using it is optional 1 Compiler Architecture source code Now we jump
More informationRunning class Timing on Java HotSpot VM, 1
Compiler construction 2009 Lecture 3. A first look at optimization: Peephole optimization. A simple example A Java class public class A { public static int f (int x) { int r = 3; int s = r + 5; return
More informationMemory Management. To do. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory
Memory Management To do q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory Memory management Ideal memory for a programmer large, fast, nonvolatile and cheap not
More informationMemory Allocation. Static Allocation. Dynamic Allocation. Dynamic Storage Allocation. CS 414: Operating Systems Spring 2008
Dynamic Storage Allocation CS 44: Operating Systems Spring 2 Memory Allocation Static Allocation (fixed in size) Sometimes we create data structures that are fixed and don t need to grow or shrink. Dynamic
More informationSimple Garbage Collection and Fast Allocation Andrew W. Appel
Simple Garbage Collection and Fast Allocation Andrew W. Appel Presented by Karthik Iyer Background Motivation Appel s Technique Terminology Fast Allocation Arranging Generations Invariant GC Working Heuristic
More informationGarbage 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 informationLecture 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 informationCS 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 informationMemory Management. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory
Memory Management q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory Memory management Ideal memory for a programmer large, fast, nonvolatile and cheap not an option
More informationOpera&ng Systems CMPSCI 377 Garbage Collec&on. Emery Berger and Mark Corner University of Massachuse9s Amherst
Opera&ng Systems CMPSCI 377 Garbage Collec&on Emery Berger and Mark Corner University of Massachuse9s Amherst Ques
More informationAutomatic 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 informationHigh Performance Managed Languages. Martin Thompson
High Performance Managed Languages Martin Thompson - @mjpt777 Really, what s your preferred platform for building HFT applications? Why would you build low-latency applications on a GC ed platform? Some
More informationName, Scope, and Binding. Outline [1]
Name, Scope, and Binding In Text: Chapter 3 Outline [1] Variable Binding Storage bindings and lifetime Type bindings Type Checking Scope Lifetime vs. Scope Referencing Environments N. Meng, S. Arthur 2
More informationG 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 informationAutomatic 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 informationGarbage 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 informationGarbage 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 informationReference Counting. Reference counting: a way to know whether a record has other users
Garbage Collection Today: various garbage collection strategies; basic ideas: Allocate until we run out of space; then try to free stuff Invariant: only the PL implementation (runtime system) knows about
More informationLecture 8 Dynamic Memory Allocation
Lecture 8 Dynamic Memory Allocation CS240 1 Memory Computer programs manipulate an abstraction of the computer s memory subsystem Memory: on the hardware side 3 @ http://computer.howstuffworks.com/computer-memory.htm/printable
More information3. Memory Management
Principles of Operating Systems CS 446/646 3. Memory Management René Doursat Department of Computer Science & Engineering University of Nevada, Reno Spring 2006 Principles of Operating Systems CS 446/646
More informationDynamic 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 informationCompiler construction 2009
Compiler construction 2009 Lecture 3 JVM and optimization. A first look at optimization: Peephole optimization. A simple example A Java class public class A { public static int f (int x) { int r = 3; int
More informationCSCI-1200 Data Structures Fall 2011 Lecture 24 Garbage Collection & Smart Pointers
CSCI-1200 Data Structures Fall 2011 Lecture 24 Garbage Collection & Smart Pointers Review from Lecture 23 Basic exception mechanisms: try/throw/catch Functions & exceptions, constructors & exceptions Today
More informationRequirements, Partitioning, paging, and segmentation
Requirements, Partitioning, paging, and segmentation Memory Management Subdividing memory to accommodate multiple processes Memory needs to be allocated efficiently to pack as many processes into memory
More informationStructure 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 information1 Dynamic Memory continued: Memory Leaks
CS104: Data Structures and Object-Oriented Design (Fall 2013) September 3, 2013: Dynamic Memory, continued; A Refresher on Recursion Scribes: CS 104 Teaching Team Lecture Summary In this lecture, we continue
More informationHigh Performance Managed Languages. Martin Thompson
High Performance Managed Languages Martin Thompson - @mjpt777 Really, what is your preferred platform for building HFT applications? Why do you build low-latency applications on a GC ed platform? Agenda
More informationLectures 13 & 14. memory management
Lectures 13 & 14 Linked lists and memory management Courtesy of Prof. Garcia (UCB) CS61C L05 Introduction to C (pt 3) (1) Review Pointers and arrays are virtually same C knows how to increment pointers
More information