A Weak Pharo Story
Video: https://youtu.be/nLEmAVVC6aQ
Thu, August 25, 3:00pm – 3:15pm
Description
Automatic garbage collection, used to free unused objects, generally provides a finalization mechanism that allows developers to execute some arbitrary code when an object was or is about to be garbage collected. This finalization mechanism, useful to free external resources, is implemented in Pharo through the usage of special weak references and a weak registry. While this finalization process was in place and working since several years, with the increase of the complexity of the Pharo IDE it demonstrated to not be sufficient. In this talk we will show some popular misconceptions of the idea of "weak" references, and how memory leaks can be (and were) created from these misconceptions. We will also show how to avoid and solve this problem, ending up in the introduction of Ephemerons in latest Pharo 6.
Bio: Guille Polito is research engineer at CNRS, France. Pharoer since 2010, he participates actively in the Pharo open source community since several years. He currently works on the modularization of Pharo where he does software archeology, refactoring, library rewriting and participates in the Virtual Machine development.
33. RefsHunter
● Shows the shortest path from one object to
another
● Fast queries
rh := RefsHunter snapshot.
rh wayFrom: (Array>>#asArray)
to: Smalltalk specialObjectsArray.
37. #2 – Avoiding Leaks
● Ephemerons are special objects used for finalization
● They do not create leaks by themselves
(as the WeakRegistry did)
● Soon in Pharo 6.0
Ephemeron Finalization
41. Ephemerons – Operational View
● When the GC passes...
● 1) It does not traverse ephemerons:
It queues them
● 2) Then
[ traverses ephemerons whose key is referenced ]
whileTrue: [
there are ephemerons with keys referenced ]