Closed rbuckton closed 2 months ago
A preview of this PR can be found at https://tc39.es/proposal-explicit-resource-management/pr/194.
I've added this for discussion in the April 2024 plenary.
Yeah technically there is no future execution which would be able to observe the instance held in [[DisposableResourceStack]] of a disposed stack, so a strict reading of the definition of liveness would make this unnecessary, but I doubt any sane implementation would check whether the stack has already been disposed when doing gc, so making this explicit is better.
I agree with @mhofman's reading. Strictly speaking, slots already don't keep things alive in and of themselves (we don't have reachability, we have liveness via observability).
Making a note doesn't hurt and makes the spec more readable. I'd call this an editorial fix, not a normative one.
+1 to @syg and @mhofman -- this is not a leak currently. If we considered every internal slot which is left with things in it to be a memory leak, we'd have to change tons and tons of stuff in the spec. If we want to give implementations a hint, we could just note at the point where you'd set it to undefined that the contents will never be used again, and they could feel free to set it to undefined.
@syg, does the latest commit align with your suggestion?
The
DisposeResources
AO fails to indicate that the resources in its[[DisposableResourceStack]]
slot will no longer be used and can be freed. As a result, aDisposableStack
will inadvertently hold resources in memory until theDisposableStack
instance is freed, which is not an intended behavior.This changes
DisposeResources
to set the[[DisposableResourceStack]]
to a new empty list, along with a NOTE indicating the resources can be freed.A PR against ecma262 is being tracked by https://github.com/rbuckton/ecma262/pull/8.
Fixes #191
/cc: @tc39/ecma262-editors