翻訳と辞書 |
Ephemeron
An Ephemeron is a data structure that solves two related problems in garbage collected systems. On the one hand, an ephemeron provides a notification when some object is about to be collected. On the other hand, an Ephemeron allows data to be associated with some object ''without'' creating a reference to that object that will prevent the object from being collected. An ephemeron is a key-value pair, where the key is the object that the ephemeron guards, notifying the system when that object is collectable, and the value can be any data associated with the object such as a property list, and which may be empty. Since the elements of the property list may refer back to the key, they may prevent collection of that key. But the ephemeron is treated specially by the garbage collector. The value field is not traced until the key is found to be reachable from the system roots other than through ephemeron keys. The set of ephemerons whose keys are only reachable from ephemeron keys are then holding onto keys that are ready to be collected; these objects are not reachable from the roots except through ephemerons. When the garbage collector detects such a set, the ephemerons are queued for notification and their keys and values are traced. Hence ephemerons both detect objects that are ready for collection and break the cycles that can prevent objects from being collected. == Description ==
In computer science, finalization occurs when a garbage collector (GC) informs an application that an object is "almost collectable". It is used to help an application maintain its invariants. Weak references may be used by a garbage collector to determine the objects that are almost collectable. Seen both as key-value pairs, the main difference between weak references and an ephemerons is the way the garbage collector treats them. For weak references, the garbage collector always follows the value in the key-value pair. For ephemerons, instead, the garbage collector doesn't follow the value but queues the ephemeron for further observation at a second stage: after the first tracing phase is done, it runs through the queue looking at each ephemeron and if its key was seen, then it follows its value. This subtle difference impacts in graphs with some kinds of cycles, where weak pairs do not describe correctly that an object ought to be "almost collectable". For example, consider a key-value pair with weak references where the key is an object and the value is a set of properties attached to the object. It is expected that when the object is ready to be collected, the properties will also go away. But if the value, possibly transitively, maps to its own key (the object), then the object will never be collected. If an ephemeron was used instead, the value woudn't have been followed unless the object was proved alive, solving the cycle. Ephemerons are similar to weak pairs, but an object in an ephemeron's key field may be classed as "almost collectable" even if it is reachable from the ephemeron's value fields.
抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Ephemeron」の詳細全文を読む
スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース |
Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.
|
|