Skip to main content

Bug Tracker

Side navigation

#13020 closed bug (worksforme)

Opened December 09, 2012 12:20AM UTC

Closed December 09, 2012 01:51AM UTC

function matcherFromTokens preventing deletion from detached DOM tree

Reported by: dawson.green@gmail.com Owned by:
Priority: undecided Milestone: None
Component: selector Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:
Description

I have been trying to track down a significant memory leak in my program. Using jQuery 1.8.2, jQuery UI 1.9.1 and Eric Hynds multiselect widget plugin, I have been tracing through the detached DOM using Chrome Developer Tools after creating and deleting several objects.

At present, I am detecting a leak in elements that are getting initialized with any jQuery UI widgets or plugins using the widget factory, and the containment view has identified the matcherFromTokens function as the source of the closure. Specifically:

matchContext creates a closure over checkContext in the return (line 4920), matchAnyContext also creates a closure over checkContext in the return (line 4923) and matchers creates a closure when checkContext is set equal to context (line 4927). The combination creates profound problems when I try to .remove() objects that have previously been initialized with anything from jQuery UI. Please mark this for getting fixed and let me know if there is anything I can do in the meantime.

Note: I am reporting this here as none of the widgets are referenced in the containment view of my developer tools. While I discovered it using jQuery UI widgets, I do believe this is an issue with the jQuery core.

Attachments (0)
Change History (1)

Changed December 09, 2012 01:51AM UTC by gibson042 comment:1

component: unfiledselector
resolution: → worksforme
status: newclosed

Look closer at lines 4925 to 4930 in your file and you'll see that the checkContext shared between all three functions gets reassigned every time the returned matcher function is called, which should release the reference to any previous value.

If you are observing differently, please create a Sizzle issue linking to a reduced test case on jsFiddle/jsbin/etc. (preferably using Sizzle directly instead of jQuery) so it can be assessed there.