real-time garbage collectionos.inf.tu-dresden.de/ezag/old/ss2005/abstracts/talk-20050701-2.pdf ·...

81
Introduction Garbage Collection Methods Summary Real-Time Garbage Collection Bertram Felgenhauer 01.07.2004 / Echtzeit-AG Bertram Felgenhauer Real-Time Garbage Collection 1/18

Upload: others

Post on 13-Aug-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Real-Time Garbage Collection

Bertram Felgenhauer

01.07.2004 / Echtzeit-AG

Bertram Felgenhauer

Real-Time Garbage Collection 1/18

Page 2: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Outline

Introduction

Garbage Collection Methods

Summary

Bertram Felgenhauer

Real-Time Garbage Collection 2/18

Page 3: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

History of Garbage Collection

1958: Garbage Collection for LISP by John McCarthy

1975: parallel GC by Edsger W. Dijkstra and others

1978: real-time GC by Henry G. Baker

1992: noncopying real-time GC by Henry G. Baker

1995: Java announced

Bertram Felgenhauer

Real-Time Garbage Collection 3/18

Page 4: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

History of Garbage Collection

1958: Garbage Collection for LISP by John McCarthy

1975: parallel GC by Edsger W. Dijkstra and others

1978: real-time GC by Henry G. Baker

1992: noncopying real-time GC by Henry G. Baker

1995: Java announced

Bertram Felgenhauer

Real-Time Garbage Collection 3/18

Page 5: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

History of Garbage Collection

1958: Garbage Collection for LISP by John McCarthy

1975: parallel GC by Edsger W. Dijkstra and others

1978: real-time GC by Henry G. Baker

1992: noncopying real-time GC by Henry G. Baker

1995: Java announced

Bertram Felgenhauer

Real-Time Garbage Collection 3/18

Page 6: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

History of Garbage Collection

1958: Garbage Collection for LISP by John McCarthy

1975: parallel GC by Edsger W. Dijkstra and others

1978: real-time GC by Henry G. Baker

1992: noncopying real-time GC by Henry G. Baker

1995: Java announced

Bertram Felgenhauer

Real-Time Garbage Collection 3/18

Page 7: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

History of Garbage Collection

1958: Garbage Collection for LISP by John McCarthy

1975: parallel GC by Edsger W. Dijkstra and others

1978: real-time GC by Henry G. Baker

1992: noncopying real-time GC by Henry G. Baker

1995: Java announced

Bertram Felgenhauer

Real-Time Garbage Collection 3/18

Page 8: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Programming Languages Using Garbage Collection

I LISP, SchemeI Python, PerlI Haskell, MLI Modula-3I Smalltalk, Self, Java

I many applications implement their own GC

Bertram Felgenhauer

Real-Time Garbage Collection 4/18

Page 9: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Programming Languages Using Garbage Collection

I LISP, SchemeI Python, PerlI Haskell, MLI Modula-3I Smalltalk, Self, Java

I many applications implement their own GC

Bertram Felgenhauer

Real-Time Garbage Collection 4/18

Page 10: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Programming Languages Using Garbage Collection

I LISP, SchemeI Python, PerlI Haskell, MLI Modula-3I Smalltalk, Self, Java

I many applications implement their own GC

Bertram Felgenhauer

Real-Time Garbage Collection 4/18

Page 11: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Programming Languages Using Garbage Collection

I LISP, SchemeI Python, PerlI Haskell, MLI Modula-3I Smalltalk, Self, Java

I many applications implement their own GC

Bertram Felgenhauer

Real-Time Garbage Collection 4/18

Page 12: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Programming Languages Using Garbage Collection

I LISP, SchemeI Python, PerlI Haskell, MLI Modula-3I Smalltalk, Self, Java

I many applications implement their own GC

Bertram Felgenhauer

Real-Time Garbage Collection 4/18

Page 13: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Programming Languages Using Garbage Collection

I LISP, SchemeI Python, PerlI Haskell, MLI Modula-3I Smalltalk, Self, Java

I many applications implement their own GC

Bertram Felgenhauer

Real-Time Garbage Collection 4/18

Page 14: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Why Do We Need Garbage Collection?

I Memory is limited.I Many programs use complex, dynamic data structures.I avoid dangling pointers

I avoid memory leaks

Bertram Felgenhauer

Real-Time Garbage Collection 5/18

Page 15: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Why Do We Need Garbage Collection?

I Memory is limited.I Many programs use complex, dynamic data structures.I avoid dangling pointers

I avoid memory leaks

Bertram Felgenhauer

Real-Time Garbage Collection 5/18

Page 16: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Why Do We Need Garbage Collection?

I Memory is limited.I Many programs use complex, dynamic data structures.I avoid dangling pointers

I avoid memory leaks

Bertram Felgenhauer

Real-Time Garbage Collection 5/18

Page 17: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Why Do We Need Garbage Collection?

I Memory is limited.I Many programs use complex, dynamic data structures.I avoid dangling pointers

I avoid memory leaks

Bertram Felgenhauer

Real-Time Garbage Collection 5/18

Page 18: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Why Do We Need Garbage Collection?

I Memory is limited.I Many programs use complex, dynamic data structures.I avoid dangling pointers

I avoid memory leaks

Bertram Felgenhauer

Real-Time Garbage Collection 5/18

Page 19: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Why Do We Need Garbage Collection?

I Memory is limited.I Many programs use complex, dynamic data structures.I avoid dangling pointers

I avoid memory leaks

???

Bertram Felgenhauer

Real-Time Garbage Collection 5/18

Page 20: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

How Does Garbage Collection Work?

I distinguish live and dead objectsI Live objects are reachable through a chain of references

starting from a root set.I All other objects are dead and can be freed (collected).I This is a safe approximation for unused objects.I The general problem reduces to the halting problem.

Bertram Felgenhauer

Real-Time Garbage Collection 6/18

Page 21: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

How Does Garbage Collection Work?

I distinguish live and dead objectsI Live objects are reachable through a chain of references

starting from a root set.I All other objects are dead and can be freed (collected).I This is a safe approximation for unused objects.I The general problem reduces to the halting problem.

Bertram Felgenhauer

Real-Time Garbage Collection 6/18

Page 22: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

How Does Garbage Collection Work?

I distinguish live and dead objectsI Live objects are reachable through a chain of references

starting from a root set.I All other objects are dead and can be freed (collected).I This is a safe approximation for unused objects.I The general problem reduces to the halting problem.

Bertram Felgenhauer

Real-Time Garbage Collection 6/18

Page 23: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

How Does Garbage Collection Work?

I distinguish live and dead objectsI Live objects are reachable through a chain of references

starting from a root set.I All other objects are dead and can be freed (collected).I This is a safe approximation for unused objects.I The general problem reduces to the halting problem.

Bertram Felgenhauer

Real-Time Garbage Collection 6/18

Page 24: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

How Does Garbage Collection Work?

I distinguish live and dead objectsI Live objects are reachable through a chain of references

starting from a root set.I All other objects are dead and can be freed (collected).I This is a safe approximation for unused objects.I The general problem reduces to the halting problem.

Bertram Felgenhauer

Real-Time Garbage Collection 6/18

Page 25: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting

I data structure with reference counts

1

1

1

3

I does not collect cyclesI Freeing objects can take very long.

Bertram Felgenhauer

Real-Time Garbage Collection 7/18

Page 26: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting

I A reference count drops to zero.

1

1

30

I does not collect cyclesI Freeing objects can take very long.

Bertram Felgenhauer

Real-Time Garbage Collection 7/18

Page 27: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting

I The object is freed. Reference counts are decremented.

30

0

0

I does not collect cyclesI Freeing objects can take very long.

Bertram Felgenhauer

Real-Time Garbage Collection 7/18

Page 28: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting

I Two more objects are freed.

00

0

1

I does not collect cyclesI Freeing objects can take very long.

Bertram Felgenhauer

Real-Time Garbage Collection 7/18

Page 29: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting

I Two more objects are freed.

00

0

1

I does not collect cyclesI Freeing objects can take very long.

Bertram Felgenhauer

Real-Time Garbage Collection 7/18

Page 30: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting

I Two more objects are freed.

00

0

1

I does not collect cyclesI Freeing objects can take very long.

Bertram Felgenhauer

Real-Time Garbage Collection 7/18

Page 31: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting in Real-Time

I Allocating an object takes constant time using a free list.I Adding references takes constant time.

I Removing references can take long.idea: Collect objects incrementally.

Bertram Felgenhauer

Real-Time Garbage Collection 8/18

Page 32: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting in Real-Time

I Allocating an object takes constant time using a free list.I Adding references takes constant time.

I Removing references can take long.idea: Collect objects incrementally.

Bertram Felgenhauer

Real-Time Garbage Collection 8/18

Page 33: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting in Real-Time

I Allocating an object takes constant time using a free list.I Adding references takes constant time.

I Removing references can take long.idea: Collect objects incrementally.

Bertram Felgenhauer

Real-Time Garbage Collection 8/18

Page 34: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting in Real-Time, ctd.

I A reference count drops to zero.

free list

1

1

30

Bertram Felgenhauer

Real-Time Garbage Collection 9/18

Page 35: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting in Real-Time, ctd.

I The object is inserted into the free list.

free list

1

1

3

Bertram Felgenhauer

Real-Time Garbage Collection 9/18

Page 36: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting in Real-Time, ctd.

I The object is allocated. Reference counts are updated.

free list

3

0

0

1

Bertram Felgenhauer

Real-Time Garbage Collection 9/18

Page 37: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Reference Counting in Real-Time, ctd.

I The free list is updated.

free list

31

Bertram Felgenhauer

Real-Time Garbage Collection 9/18

Page 38: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Assumptions of Real-Time Garbage Collection

I The number of reachable objects is limited by a constant Mat any given moment in time.

I There is enough memory in the system:I For reference counting, this is M + ε.I For other methods it may be more.

I For reference counting, the program must notcreate cycles.

Bertram Felgenhauer

Real-Time Garbage Collection 10/18

Page 39: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Assumptions of Real-Time Garbage Collection

I The number of reachable objects is limited by a constant Mat any given moment in time.

I There is enough memory in the system:I For reference counting, this is M + ε.I For other methods it may be more.

I For reference counting, the program must notcreate cycles.

Bertram Felgenhauer

Real-Time Garbage Collection 10/18

Page 40: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Assumptions of Real-Time Garbage Collection

I The number of reachable objects is limited by a constant Mat any given moment in time.

I There is enough memory in the system:I For reference counting, this is M + ε.I For other methods it may be more.

I For reference counting, the program must notcreate cycles.

Bertram Felgenhauer

Real-Time Garbage Collection 10/18

Page 41: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Assumptions of Real-Time Garbage Collection

I The number of reachable objects is limited by a constant Mat any given moment in time.

I There is enough memory in the system:I For reference counting, this is M + ε.I For other methods it may be more.

I For reference counting, the program must notcreate cycles.

Bertram Felgenhauer

Real-Time Garbage Collection 10/18

Page 42: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Assumptions of Real-Time Garbage Collection

I The number of reachable objects is limited by a constant Mat any given moment in time.

I There is enough memory in the system:I For reference counting, this is M + ε.I For other methods it may be more.

I For reference counting, the program must notcreate cycles.

Bertram Felgenhauer

Real-Time Garbage Collection 10/18

Page 43: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

I data structure

root set

from−space to−space

Bertram Felgenhauer

Real-Time Garbage Collection 11/18

Page 44: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

I live and dead objects

from−space

root set

to−space

Bertram Felgenhauer

Real-Time Garbage Collection 11/18

Page 45: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

I garbage collection: copy first object from root set

root set

from−space to−space

Bertram Felgenhauer

Real-Time Garbage Collection 11/18

Page 46: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

I leave forwarding pointer in from-space

root set

from−space to−space

Bertram Felgenhauer

Real-Time Garbage Collection 11/18

Page 47: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

I continue copying to to-space

to−space

root set

from−space

Bertram Felgenhauer

Real-Time Garbage Collection 11/18

Page 48: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

I continue copying to to-space

root set

from−space to−space

Bertram Felgenhauer

Real-Time Garbage Collection 11/18

Page 49: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

I continue copying to to-space

from−space to−space

root set

Bertram Felgenhauer

Real-Time Garbage Collection 11/18

Page 50: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

I continue copying to to-space

root set

from−space to−space

Bertram Felgenhauer

Real-Time Garbage Collection 11/18

Page 51: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

I follow forwarding pointer

root set

from−space to−space

Bertram Felgenhauer

Real-Time Garbage Collection 11/18

Page 52: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

I to-space only contains garbage now. Swap spaces.

root set

to−space from−space

Bertram Felgenhauer

Real-Time Garbage Collection 11/18

Page 53: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

advantages:I can collect cyclic data structuresI allocation can be implemented by incrementing a pointerI more memory means less time collecting garbageI improves locality of reference

disadvantages:I long pause timesI requires at least 2M memory and a stack for the

garbage collection

Bertram Felgenhauer

Real-Time Garbage Collection 12/18

Page 54: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

advantages:I can collect cyclic data structuresI allocation can be implemented by incrementing a pointerI more memory means less time collecting garbageI improves locality of reference

disadvantages:I long pause timesI requires at least 2M memory and a stack for the

garbage collection

Bertram Felgenhauer

Real-Time Garbage Collection 12/18

Page 55: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

advantages:I can collect cyclic data structuresI allocation can be implemented by incrementing a pointerI more memory means less time collecting garbageI improves locality of reference

disadvantages:I long pause timesI requires at least 2M memory and a stack for the

garbage collection

Bertram Felgenhauer

Real-Time Garbage Collection 12/18

Page 56: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

advantages:I can collect cyclic data structuresI allocation can be implemented by incrementing a pointerI more memory means less time collecting garbageI improves locality of reference

disadvantages:I long pause timesI requires at least 2M memory and a stack for the

garbage collection

Bertram Felgenhauer

Real-Time Garbage Collection 12/18

Page 57: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

advantages:I can collect cyclic data structuresI allocation can be implemented by incrementing a pointerI more memory means less time collecting garbageI improves locality of reference

disadvantages:I long pause timesI requires at least 2M memory and a stack for the

garbage collection

Bertram Felgenhauer

Real-Time Garbage Collection 12/18

Page 58: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection – Two Space Approach

advantages:I can collect cyclic data structuresI allocation can be implemented by incrementing a pointerI more memory means less time collecting garbageI improves locality of reference

disadvantages:I long pause timesI requires at least 2M memory and a stack for the

garbage collection

Bertram Felgenhauer

Real-Time Garbage Collection 12/18

Page 59: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time

I interleave operation of application and garbage collectorI copy one object from from-space to to-space for every

allocated object

I prevent application from seeing pointers toforwarding pointers

I forbid application to create pointers from to-spaceto from-space

I allocate new objects in to-space

Bertram Felgenhauer

Real-Time Garbage Collection 13/18

Page 60: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time

I interleave operation of application and garbage collectorI copy one object from from-space to to-space for every

allocated object

I prevent application from seeing pointers toforwarding pointers

I forbid application to create pointers from to-spaceto from-space

I allocate new objects in to-space

Bertram Felgenhauer

Real-Time Garbage Collection 13/18

Page 61: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time

I interleave operation of application and garbage collectorI copy one object from from-space to to-space for every

allocated object

I prevent application from seeing pointers toforwarding pointers

I forbid application to create pointers from to-spaceto from-space

I allocate new objects in to-space

Bertram Felgenhauer

Real-Time Garbage Collection 13/18

Page 62: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time

I interleave operation of application and garbage collectorI copy one object from from-space to to-space for every

allocated object

I prevent application from seeing pointers toforwarding pointers

I forbid application to create pointers from to-spaceto from-space

I allocate new objects in to-space

Bertram Felgenhauer

Real-Time Garbage Collection 13/18

Page 63: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time

I interleave operation of application and garbage collectorI copy one object from from-space to to-space for every

allocated object

I prevent application from seeing pointers toforwarding pointers

I forbid application to create pointers from to-spaceto from-space

I allocate new objects in to-space

Bertram Felgenhauer

Real-Time Garbage Collection 13/18

Page 64: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time, ctd.

prevent application from seeing pointers to forwarding pointersI idea: have a forwarding pointer in all objects

I always forward all pointers before accessing memorya = a->fwd; /* forward */b = a->left;

Bertram Felgenhauer

Real-Time Garbage Collection 14/18

Page 65: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time, ctd.

prevent application from seeing pointers to forwarding pointersI idea: have a forwarding pointer in all objects

I always forward all pointers before accessing memorya = a->fwd; /* forward */b = a->left;

Bertram Felgenhauer

Real-Time Garbage Collection 14/18

Page 66: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time, ctd.

forbid creating pointers from to-space to from-space:I idea: copy object before creating a pointer to it

a = a->fwd; /* forward */if (in_from_space(a))

a = copy_to_to_space(a);b = b->fwd; /* forward */b->left = a;

Bertram Felgenhauer

Real-Time Garbage Collection 15/18

Page 67: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time, ctd.

forbid creating pointers from to-space to from-space:I idea: copy object before creating a pointer to it

a = a->fwd; /* forward */if (in_from_space(a))

a = copy_to_to_space(a);b = b->fwd; /* forward */b->left = a;

Bertram Felgenhauer

Real-Time Garbage Collection 15/18

Page 68: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time – Summary

I additional assumption: there is a maximum object sizeI requires at most 4M memoryI features fast read access to dataI write access can be slow (but takes bounded time)

Bertram Felgenhauer

Real-Time Garbage Collection 16/18

Page 69: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time – Summary

I additional assumption: there is a maximum object sizeI requires at most 4M memoryI features fast read access to dataI write access can be slow (but takes bounded time)

Bertram Felgenhauer

Real-Time Garbage Collection 16/18

Page 70: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time – Summary

I additional assumption: there is a maximum object sizeI requires at most 4M memoryI features fast read access to dataI write access can be slow (but takes bounded time)

Bertram Felgenhauer

Real-Time Garbage Collection 16/18

Page 71: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Copying Garbage Collection in Real-Time – Summary

I additional assumption: there is a maximum object sizeI requires at most 4M memoryI features fast read access to dataI write access can be slow (but takes bounded time)

Bertram Felgenhauer

Real-Time Garbage Collection 16/18

Page 72: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Other Approaches

I parallel GC – three color marking (Djikstra and others)I aim for good performance and soft real time:

I let collector work on larger chunksI probability of missing a deadline can be reduced

by adding more memory (Bacon and others)

Bertram Felgenhauer

Real-Time Garbage Collection 17/18

Page 73: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Other Approaches

I parallel GC – three color marking (Djikstra and others)I aim for good performance and soft real time:

I let collector work on larger chunksI probability of missing a deadline can be reduced

by adding more memory (Bacon and others)

Bertram Felgenhauer

Real-Time Garbage Collection 17/18

Page 74: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Other Approaches

I parallel GC – three color marking (Djikstra and others)I aim for good performance and soft real time:

I let collector work on larger chunksI probability of missing a deadline can be reduced

by adding more memory (Bacon and others)

Bertram Felgenhauer

Real-Time Garbage Collection 17/18

Page 75: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

Other Approaches

I parallel GC – three color marking (Djikstra and others)I aim for good performance and soft real time:

I let collector work on larger chunksI probability of missing a deadline can be reduced

by adding more memory (Bacon and others)

Bertram Felgenhauer

Real-Time Garbage Collection 17/18

Page 76: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

SummaryI There is demand for real-time garbage collection.I Real-time garbage collection is feasible.

OutlookI more garbage collection approachesI many small improvementsI target soft real-time to achieve higher performance

Questions?

Bertram Felgenhauer

Real-Time Garbage Collection 18/18

Page 77: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

SummaryI There is demand for real-time garbage collection.I Real-time garbage collection is feasible.

OutlookI more garbage collection approachesI many small improvementsI target soft real-time to achieve higher performance

Questions?

Bertram Felgenhauer

Real-Time Garbage Collection 18/18

Page 78: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

SummaryI There is demand for real-time garbage collection.I Real-time garbage collection is feasible.

OutlookI more garbage collection approachesI many small improvementsI target soft real-time to achieve higher performance

Questions?

Bertram Felgenhauer

Real-Time Garbage Collection 18/18

Page 79: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

SummaryI There is demand for real-time garbage collection.I Real-time garbage collection is feasible.

OutlookI more garbage collection approachesI many small improvementsI target soft real-time to achieve higher performance

Questions?

Bertram Felgenhauer

Real-Time Garbage Collection 18/18

Page 80: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

SummaryI There is demand for real-time garbage collection.I Real-time garbage collection is feasible.

OutlookI more garbage collection approachesI many small improvementsI target soft real-time to achieve higher performance

Questions?

Bertram Felgenhauer

Real-Time Garbage Collection 18/18

Page 81: Real-Time Garbage Collectionos.inf.tu-dresden.de/EZAG/old/ss2005/abstracts/talk-20050701-2.pdf · 1995: Java announced Bertram Felgenhauer Real-Time Garbage Collection 3/18. Introduction

Introduction Garbage Collection Methods Summary

SummaryI There is demand for real-time garbage collection.I Real-time garbage collection is feasible.

OutlookI more garbage collection approachesI many small improvementsI target soft real-time to achieve higher performance

Questions?

Bertram Felgenhauer

Real-Time Garbage Collection 18/18