Skip to content

Avoid memory leaks during refresh - DO NOT MERGE #1288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

scottgonzalez
Copy link
Member

This is intended to get some discussion around a solution for memory leaks around elements that are removed during a refresh (http://bugs.jqueryui.com/ticket/10056).

Unfortunately, I don't think there's a general solution we can apply. Every widget that handles a refresh will need to manually track the removed elements and pass them to ._off().

this._off( prevTabs.not( this.tabs ) );
this._off( prevAnchors.not( this.anchors ) );
this._off( prevPanels.not( this.panels ) );
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually shouldn't be too hard to manage, since we're already tracking the elements in each widget. We can either have a conditional like this or initialize all the properties to empty jQuery objects to avoid calling .not() on undefined. We'll just need to go through every widget and make sure we're doing this.

@tjvantoll
Copy link
Member

This approach seems sane to me. At the very least I can't think of a better way of avoiding the problem.

If we apply this approach to all widgets, I worry that this could regress fairly easily though. Is there any way we could test this? Something like verifying that references have been removed from bindings, focusable, and hoverable?

@scottgonzalez
Copy link
Member Author

I discussed testing and regressing with @tjvantoll in IRC and we agreed that the chances for regression are fairly low and the tests would need to test private properties from the base widget, so we won't be adding tests for this.

I'm going to close this and put together a new PR with proper commits now that we've agreed on the approach.

@scottgonzalez scottgonzalez deleted the refresh-unbinding branch August 20, 2014 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants