7 ms·
Collecting exactly the dead objects in all situations is not possible even in theory: function f() { x = Object(1) if (halts(some_program))
by sweeneyrod 7y ago
Collecting exactly the dead objects in all situations is not possible even in theory:
function f() {
x = Object(1)
if (halts(some_program)) {
return Object(2)
} else {
return x;
}
}
The contents of x will be dead or not after the assignment depending on whether some_program halts. But a GC that could determine that could solve the halting problem.
- zamadatix 7y agoThat code doesn't make any sense. Either halts() itself is a function that solves the halting problem or the else branch is a dead branch because in order to be selected halts() must have never returned. Dynamic code is where the GC can't know if something simply has a stale reference or if the codepath that calls it simply doesn't exist yet. It's be interesting to need to tag such data appropriately as that opens up a lot of leak protection.
- sweeneyrod 7y agoYep, you're right. I should've just said that the condition of the if statement can in general be undecidable.