-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11667 from emberjs/stefanpenner-memory-leak
[BUGFIX release] Fix Glimmer memory leak
- Loading branch information
Showing
15 changed files
with
199 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export default function didCleanupTree(env) { | ||
var view; | ||
if (view = env.view) { | ||
view.ownerView.isDestroyingSubtree = false; | ||
} | ||
// Once we have finsihed cleaning up the render node and sub-nodes, reset | ||
// state tracking which view those render nodes belonged to. | ||
env.view.ownerView._destroyingSubtreeForView = null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
export default function willCleanupTree(env, morph, destroySelf) { | ||
var view = morph.emberView; | ||
if (destroySelf && view && view.parentView) { | ||
view.parentView.removeChild(view); | ||
} | ||
export default function willCleanupTree(env) { | ||
let view = env.view; | ||
|
||
if (view = env.view) { | ||
view.ownerView.isDestroyingSubtree = true; | ||
} | ||
// When we go to clean up the render node and all of its children, we may | ||
// encounter views/components associated with those nodes along the way. In | ||
// those cases, we need to make sure we need to sever the link between the | ||
// existing view hierarchy and those views. | ||
// | ||
// However, we do *not* need to remove the child views of child views, since | ||
// severing the connection to their parent effectively severs them from the | ||
// view graph. | ||
// | ||
// For example, imagine the following view graph: | ||
// | ||
// A | ||
// / \ | ||
// B C | ||
// / \ | ||
// D E | ||
// | ||
// If we are cleaning up the node for view C, we need to remove that view | ||
// from A's child views. However, we do not need to remove D and E from C's | ||
// child views, since removing C transitively removes D and E as well. | ||
// | ||
// To accomplish this, we track the nearest view to this render node on the | ||
// owner view, the root-most view in the graph (A in the example above). If | ||
// we detect a view that is a direct child of that view, we remove it from | ||
// the `childViews` array. Other parent/child view relationships are | ||
// untouched. This view is then cleared once cleanup is complete in | ||
// `didCleanupTree`. | ||
view.ownerView._destroyingSubtreeForView = view; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters