Assignment 6 - Garbage collection and weak references

Jannis
Mausschubser
Mausschubser
Beiträge: 63
Registriert: 15. Apr 2015 17:10

Assignment 6 - Garbage collection and weak references

Beitrag von Jannis » 17. Dez 2017 21:50

Hi,

in the second task of assignment 6, do we really need to trigger every WeakRefV in the store to be invalid for every call of the garbage collection (A), or only the ones which point to null values (B)? I personally think that (B) makes more sense, but the text in the task sounds more like (A) to me. Additionally, both versions pass the given tests.
Assignment 6 task 2 hat geschrieben:Each garbage collection must trigger every WeakRefV in the store to be invalid,
i.e. rewrite the reference in the WeakRefV to the given value INVALID_LOC.

mirko-koehler
Mausschubser
Mausschubser
Beiträge: 79
Registriert: 16. Okt 2017 12:28

Re: Assignment 6 - Garbage collection and weak references

Beitrag von mirko-koehler » 18. Dez 2017 11:25

In general, both makes sense. In the task description, we have explained the case (A), because it is easier to satisfy correctness guarantees, i.e. that a weak ref never points to a null value. However, in (B) the weak reference persists as long as the value it references exists (for example, if there is another strong reference to the value).

You can implement either variant, (A) or (B). But take care in (B) that the referenced value of a weak reference is not null after the garbage collection. :)

Antworten

Zurück zu „Archiv“