Opened 7 years ago

Closed 7 years ago

Last modified 3 years ago

#9555 closed bug (patcheswelcome)

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.

Change History (8)

comment:1 Changed 7 years ago by kpturner

Apologies - wrong fiddle:

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

comment:2 in reply to:  1 Changed 7 years ago by tj.vantoll

Owner: set to kpturner
Status: newpending

Replying to 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.

comment:3 Changed 7 years ago by kpturner

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.

comment:4 in reply to:  3 Changed 7 years ago by tj.vantoll

Replying to 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...

comment:5 Changed 7 years ago by tj.vantoll

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.

comment:6 Changed 7 years ago by kpturner

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.

comment:7 Changed 6 years ago by Scott González

#10629 is a duplicate of this ticket.

comment:8 Changed 3 years ago by Scott González

#15143 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.