Who Takes Out Your Trash?

A presentation at Webcamp Zagreb in October 2018 in Zagreb, Croatia by Sanne Kalkman

Slide 1

Slide 1

WHO TAKES OUT YOUR TRASH? @sannekalkman

Slide 2

Slide 2

Slide 3

Slide 3

🔮

Slide 4

Slide 4

🔮 💻

Slide 5

Slide 5

🔮 💻 Magic is just (computer) science you don’t understand yet

Slide 6

Slide 6

Slide 7

Slide 7

🧠 Allocate memory

Slide 8

Slide 8

🧠 🔍 Allocate memory Find the garbage

Slide 9

Slide 9

🧠 🔍 🗑 Allocate memory Find the garbage Free up memory

Slide 10

Slide 10

REFERENCE COUNTING If nothing points to it, nothing’s using it

Slide 11

Slide 11

REFERENCE COUNTING

Slide 12

Slide 12

REFERENCE COUNTING name = "webcamp"

Slide 13

Slide 13

REFERENCE COUNTING name name = "webcamp" "webcamp" 1

Slide 14

Slide 14

REFERENCE COUNTING name name = "webcamp" other_name = name "webcamp" 1

Slide 15

Slide 15

REFERENCE COUNTING name name = "webcamp" other_name = name "webcamp" other_name 2

Slide 16

Slide 16

REFERENCE COUNTING name name = "webcamp" other_name = name "webcamp" name = nil other_name 2

Slide 17

Slide 17

REFERENCE COUNTING name name = "webcamp" other_name = name "webcamp" name = nil other_name 1

Slide 18

Slide 18

REFERENCE COUNTING name name = "webcamp" other_name = name "webcamp" name = nil other_name = nil other_name 1

Slide 19

Slide 19

REFERENCE COUNTING name name = "webcamp" other_name = name "webcamp" name = nil other_name = nil other_name 0

Slide 20

Slide 20

REFERENCE COUNTING name name = "webcamp" other_name = name "webcamp" name = nil other_name = nil other_name 0

Slide 21

Slide 21

CYCLES

Slide 22

Slide 22

CYCLES one = { other: nil }

Slide 23

Slide 23

CYCLES one = { other: nil } one { other: nil } 1

Slide 24

Slide 24

CYCLES one = { other: nil } two = { other: one } one { other: nil } 1

Slide 25

Slide 25

CYCLES one = { other: nil } one { other: nil } 1 two { other: one } 1 two = { other: one }

Slide 26

Slide 26

CYCLES one = { other: nil } one { other: nil } 2 two { other: one } 1 two = { other: one }

Slide 27

Slide 27

CYCLES one = { other: nil } one { other: nil } 2 two { other: one } 1 two = { other: one } one[:other] = two

Slide 28

Slide 28

CYCLES one = { other: nil } one { other: two } 2 two { other: one } 1 two = { other: one } one[:other] = two

Slide 29

Slide 29

CYCLES one = { other: nil } one { other: two } 2 two { other: one } 2 two = { other: one } one[:other] = two

Slide 30

Slide 30

CYCLES one = { other: nil } one { other: two } 2 two { other: one } 2 two = { other: one } one[:other] = two one = nil two = nil

Slide 31

Slide 31

CYCLES one = { other: nil } one { other: two } 1 two { other: one } 2 two = { other: one } one[:other] = two one = nil two = nil

Slide 32

Slide 32

CYCLES one = { other: nil } one { other: two } 1 two { other: one } 1 two = { other: one } one[:other] = two one = nil two = nil

Slide 33

Slide 33

MARK & SWEEP If you can’t get to it, you can’t be using it

Slide 34

Slide 34

MARK & SWEEP

Slide 35

Slide 35

MARK & SWEEP

Slide 36

Slide 36

MARK & SWEEP

Slide 37

Slide 37

MARK & SWEEP

Slide 38

Slide 38

MARK & SWEEP

Slide 39

Slide 39

MARK & SWEEP

Slide 40

Slide 40

MARK & SWEEP

Slide 41

Slide 41

MARK & SWEEP

Slide 42

Slide 42

MARK & SWEEP

Slide 43

Slide 43

COPYING COLLECTION Keep your stuff together

Slide 44

Slide 44

COPYING COLLECTION 0 2 3 4 5 7

Slide 45

Slide 45

COPYING COLLECTION 0 0 2 3 4 5 7

Slide 46

Slide 46

COPYING COLLECTION 0 0 2 2 3 4 5 7

Slide 47

Slide 47

COPYING COLLECTION 0 0 2 2 3 3 4 5 7

Slide 48

Slide 48

COPYING COLLECTION 0 0 2 2 3 3 4 4 5 7

Slide 49

Slide 49

COPYING COLLECTION 0 0 2 2 3 4 3 4 5 5 7

Slide 50

Slide 50

COPYING COLLECTION 0 0 2 2 3 4 5 3 4 5 7 7

Slide 51

Slide 51

COPYING COLLECTION 0 0 2 2 3 4 5 3 4 5 7 7

Slide 52

Slide 52

GENERATIONAL COLLECTION If you’ve been using it for a while, it’s probably important

Slide 53

Slide 53

GENERATIONAL COLLECTION New objects Old objects D

Slide 54

Slide 54

GENERATIONAL COLLECTION New objects Old objects D

Slide 55

Slide 55

GENERATIONAL COLLECTION New objects Old objects D

Slide 56

Slide 56

GENERATIONAL COLLECTION New objects Old objects D

Slide 57

Slide 57

GENERATIONAL COLLECTION New objects Old objects D

Slide 58

Slide 58

GENERATIONAL COLLECTION New objects Old objects D

Slide 59

Slide 59

GENERATIONAL COLLECTION New objects Old objects D

Slide 60

Slide 60

GENERATIONAL COLLECTION New objects Old objects D

Slide 61

Slide 61

GENERATIONAL COLLECTION New objects Old objects D

Slide 62

Slide 62

GENERATIONAL COLLECTION New objects Old objects D

Slide 63

Slide 63

GENERATIONAL COLLECTION New objects Old objects D

Slide 64

Slide 64

GENERATIONAL COLLECTION New objects Old objects D

Slide 65

Slide 65

GENERATIONAL COLLECTION New objects Old objects D

Slide 66

Slide 66

🔮 💻 Garbage collection is no longer magic!

Slide 67

Slide 67

LET ME KNOW WHAT YOU THINK! Rate this talk at joind.in Tweet me @sannekalkman Find me in person later!