Skip to content

value leaks inside closure inside closure inside closure #30189

Closed

Description

The listener is alive for the lifetime of the model, and somehow manages to capture value, which is the initial text content of the model.

screen shot 2017-07-06 at 16 16 33

fyi Benjamin Pasero (@bpasero) Daniel Imms (@Tyriar) -- I will detangle the closures to avoid capturing value in the listener.

Activity

  1. added
    bug
    important
    on Jul 6, 2017
  2. bpasero commented on Jul 6, 2017

    @bpasero
    Contributor

    alexandrudima thanks. I wonder why the local variables are captured even though not being used within the closure.

  3. alexdima commented on Jul 6, 2017

    @alexdima
    MemberAuthor

    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.

  4. alexdima commented on Jul 6, 2017

    @alexdima
    MemberAuthor

    here is a graphical explanation:

    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.

    screen shot 2017-07-06 at 19 51 22

  5. bpasero commented on Jul 7, 2017

    @bpasero
    Contributor

    Yes please 👍

  6. alexdima commented on Jul 7, 2017

    @alexdima
    MemberAuthor

    Initial shape of the code:
    screen shot 2017-07-07 at 09 58 36

  7. added
    verified
    on Aug 2, 2017
  8. locked and limited conversation to collaborators on Nov 17, 2017
  9. added a commit that references this issue on Sep 6, 2026
    b5cd2d0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugimportantverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions