Advertisement
Guest User

Untitled

a guest
May 25th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. From the spec's point of view, all objects live forever. Garbage collection is
  2. just an optimization, permitted only because it is undetectable. Even though
  3. weak references are generally seen as making GC visible, we can actually
  4. specify weak references in a way that preserves the traditional approach: the
  5. spec will still assume all objects live forever, and will merely describe when
  6. it is permitted to remove certain edges to them.
  7.  
  8. An object is "relevant" if replacing it with any arbitrary other object could
  9. have a visible effect on the future execution of the program.
  10.  
  11. If there is a set of weak references such that none of their referent objects
  12. are relevant unless some weak reference within the set is followed, then it is
  13. permitted to cut all references in the set.
  14.  
  15. Suppose an object `A` is pointed to by a weak reference `B`, and by a variable.
  16. Consider the set `{B}`: `A` is certainly relevant even if `{B}` is never followed,
  17. since `A` can be used via the variable.
  18.  
  19. However, if the implementation can prove that the variable will never be used,
  20. then `A` can only be relevant if `B` is dereferenced, and it is permitted to cut
  21. all the references in `{B}` (in other words, just `B` itself).
  22.  
  23. Suppose two weak references `R` and `S` point to two objects `O`
  24. and `P`. Suppose further that the two objects point to each
  25. other, but are not otherwise reachable.
  26.  
  27. - Consider the set `{R}`. Certainly `O` is relevant even if `R` is not followed; it
  28. is reachable via `S`, and then `P`. It is not permitted to clear `R` alone.
  29.  
  30. - Consider the set `{R, S}`. `O` and `P` are irrelevant unless some weak reference
  31. in `{R, S}` is followed, so it is permitted to clear `R` and `S` simultaneously.
  32.  
  33. Suppose, in addition to `O`, `P`, `R`, and `S`, there is another object `Q` reachable
  34. only via a weak reference `T`; `Q` itself refers to nothing else. Consider the set
  35. `{R, S, T}`: none of their referent objects are relevant unless some weak
  36. reference in that set is followed, so it is permitted to cut all three
  37. together.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement