Skip to main content

Search and Top Navigation

#9555 closed bug (patcheswelcome)

Opened September 13, 2013 07:24PM UTC

Closed September 16, 2013 01:30PM UTC

Last modified March 05, 2017 03:59PM UTC

Datepicker seems to leak an HTMLDivElement into a detached DOM tree

Reported by: kpturner Owned by: kpturner
Priority: minor Milestone: none
Component: ui.datepicker Version: 1.9.2
Keywords: Cc:
Blocked by: Blocking:
Description

When jQuery loads up and initialises the datepicker widget, it seems to leak memory - although I do not think it is serious.

http://jsfiddle.net/kpturner/A7yQR/

Run this in Google Chrome, open the developer tools and tape a heap snapshot. You will find a detached DOM tree with three entries. Expanding this will show an HTMLDivElement that has been deleted but is still referenced - so it is unable to be picked up by the GC.

Not tested with 1.10.3 yet - sorry.

Attachments (0)
Change History (8)

Changed September 13, 2013 07:28PM UTC by kpturner comment:1

Apologies - wrong fiddle:

http://jsfiddle.net/kpturner/A7yQR/2/

Changed September 16, 2013 01:03PM UTC by tj.vantoll comment:2

owner: → kpturner
status: newpending

Replying to [comment:1 kpturner]:

Apologies - wrong fiddle: http://jsfiddle.net/kpturner/A7yQR/2/

I have no idea what you're trying to show in that fiddle, it's using an ancient version of jQuery UI and doesn't have a datepicker. Could you create a test case that shows the problem?

Also we're unlikely to do anything about this as the datepicker is in the process of being rewritten.

Changed September 16, 2013 01:18PM UTC by kpturner comment:3

status: pendingnew

I am sorry - maybe I didn't make it clear in the original ticket. The point is that you don't have to do anything at all with the datepicker. It occurs simply by including jqueryUI in your application. Part of the initialization process sets up various things including the datepicker, and then leaves an HTML element referenced in a detached DOM tree. The jsfiddle is there purely to load the libraries and does nothing of interest. I am only using jsfiddle because your instructions ask me to, and therefore I can only reference version of jQuery UI that jsfiddle allows - 1.8.9

How does one use jsfiddle to include the latest version of jQuery UI?

If it is in the process of being rewritten then maybe it can be ignored anyway.

Changed September 16, 2013 01:27PM UTC by tj.vantoll comment:4

Replying to [comment:3 kpturner]:

I am sorry - maybe I didn't make it clear in the original ticket. The point is that you don't have to do anything at all with the datepicker. It occurs simply by including jqueryUI in your application. Part of the initialization process sets up various things including the datepicker, and then leaves an HTML element referenced in a detached DOM tree. The jsfiddle is there purely to load the libraries and does nothing of interest. I am only using jsfiddle because your instructions ask me to, and therefore I can only reference version of jQuery UI that jsfiddle allows - 1.8.9 How does one use jsfiddle to include the latest version of jQuery UI? If it is in the process of being rewritten then maybe it can be ignored anyway.

Ah ok, makes sense. We've heard of this before.

For jsFiddle you can add the newer versions from a CDN as external resources, for example http://jsfiddle.net/tj_vantoll/b6p7M/.

We are unlikely to fix this but I'm very curious what's going on here since it's just including the script that causes this. Because to the best of my knowledge datepicker doesn't do anything before it's called...

Changed September 16, 2013 01:30PM UTC by tj.vantoll comment:5

resolution: → patcheswelcome
status: newclosed

I shouldn't say we're unlikely to fix this, more that we're unlikely to take the time to look into this as the rewrite is in process.

If you or anyone else can come up with a fix for this we'd be happy to review a pull request.

Changed September 16, 2013 02:37PM UTC by kpturner comment:6

OK - well if you go to your example jsfiddle in Chrome, you don't have to run anything or do anything (apart from load up the fiddle). Open up the Chrome Developer tools, and take a Heap Snapshot from the Profiles tab. Resequence the results by Constructor and look for Detached DOM tree. You will see one with three entries, and expanding them will show an HTMLDivElement in red that is being referenced by the Datepicker code.

As I said, I am not sure it is too serious if it only happens at startup. It is more of an issue if it leaks every time you create a datepicker.

I have not investigated the cause as yet.

Changed September 29, 2014 12:28PM UTC by scottgonzalez comment:7

#10629 is a duplicate of this ticket.

Changed March 05, 2017 03:59PM UTC by scottgonzalez comment:8

#15143 is a duplicate of this ticket.