Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

SCOPE DESTRUCTION: Leak when asynchronously continuing the linking of directives on scopes that are already destroyed #9199

Closed

Description

@lgalfaso

When a directive uses a templateUrl, this directive is inside an ng-switch or an ng-if and the following events happen in this specific order

  • The html of the ng-switch starts it's compilation
  • The directive inside the ng-switch starts it's compilation, the template is requested from the server
  • The synchronous part of the compilation ends
  • The condition on the ng-switch changes so the directive should be displayed
  • ng-switch transcludes the content of the ng-switch-when (only what it can as the template did not finish loading)
  • The expression at ng-switch changes so the directive should not be displayed
  • ng-switch destroys the scope
  • The template finishes loading, the scope (even when it is already destroyed) is added to the element.data (here is where we have the leak)

Here is a plunker that shows this
http://plnkr.co/edit/tNMYYHgoebX1Vx0hWZAb?p=preview

Note: This issue is based on a modification of #9197

Activity

  1. changed the title [-]Leak when asynchronously continuing the compilation of nodes[/-] [+]Leak when asynchronously continuing the linking of directives on scopes that are already destroyed[/+] on Sep 21, 2014
  2. caitp commented on Sep 21, 2014

    @caitp
    Contributor

    did we really need to create a new issue for this? it's basically the same thing as the one you were commenting on is it not?

  3. lgalfaso commented on Sep 21, 2014

    @lgalfaso
    ContributorAuthor

    @caitp I created the new issue to be sure it is tracked as a leak and not as something that can cause no harm. That said, I am ok with just moving everything to the original issue

  4. added a commit that references this issue on Sep 22, 2014
    e21c2f5
  5. lgalfaso commented on Sep 22, 2014

    @lgalfaso
    ContributorAuthor

    Posted an update on #9079 that solves this issue

  6. added this to the 1.3.0-rc.3 milestone on Sep 22, 2014
  7. petebacondarwin commented on Sep 26, 2014

    @petebacondarwin
    Contributor

    I commented on the two commits in #9079. I believe the commit that prevents double destroy events could cause memory leaks and proposed a different solution of actually recursing down the scope hierarchy and calling $destroy on all descendants, based on the fact that #9281 would make the scope hierarchy more conducive to this - currently this would fail to destroy transcluded scopes.
    I think the second commit is the right thing to do assuming that we really have destroyed the descendant scopes.

  8. changed the title [-]Leak when asynchronously continuing the linking of directives on scopes that are already destroyed[/-] [+]SCOPE DESTRUCTION: Leak when asynchronously continuing the linking of directives on scopes that are already destroyed[/+] on Sep 26, 2014
  9. added 3 commits that reference this issue on Sep 28, 2014
    7a29630
    56c7eb3
    1598639
  10. added 2 commits that reference this issue on Sep 29, 2014
    3c8c88e
    5c9c197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions