You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
value leaks inside closure inside closure inside closure #30189
Possibly because this is _this and is captured in the original closure. Then a second-level closure captures value, so _this and value are marked for survival in the top level method. The listener captures _this, and I think therefore also gets value.
From the outer scope, _this, resource and value will survive, and they get packaged in a system/Context.
The listener closure also points to the same system/Context scope, which now prevents value and resource from being GCed, even if the closure only uses _this.
Maybe I should present this in the standup tomorrow, it is a very interesting leak.
Activity
bpasero commentedon Jul 6, 2017
alexandrudima thanks. I wonder why the local variables are captured even though not being used within the closure.
alexdima commentedon Jul 6, 2017
Possibly because
thisis_thisand is captured in the original closure. Then a second-level closure capturesvalue, so_thisandvalueare marked for survival in the top level method. The listener captures_this, and I think therefore also getsvalue.alexdima commentedon Jul 6, 2017
here is a graphical explanation:
From the outer scope,
_this,resourceandvaluewill survive, and they get packaged in asystem/Context.The listener closure also points to the same
system/Contextscope, which now preventsvalueandresourcefrom being GCed, even if the closure only uses_this.Maybe I should present this in the standup tomorrow, it is a very interesting leak.
bpasero commentedon Jul 7, 2017
Yes please 👍
alexdima commentedon Jul 7, 2017
Initial shape of the code:

Fixes microsoft#30189: Do not leak lines array in change listener clo…