Skip to main content

Bug Tracker

Side navigation

#11809 closed bug (fixed)

Opened May 24, 2012 12:16PM UTC

Closed June 26, 2012 06:50PM UTC

Last modified November 05, 2013 10:15PM UTC

Memory leak in .text(val) setter?

Reported by: Owned by: gibson042
Priority: low Milestone: 1.8
Component: manipulation Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

When hovering over an element multiple times I've noticed Chrome Dev Tools up my dom node count which very quickly gets high.

Is this supposed to happen?


Open in Chrome

Open Dev tools, navigate to Timeline, then click memory. Set your timeline to record.

Hover on and off the black square and watch the DOM NODE COUNT go up and up.

Is this a memory leak?

Attachments (0)
Change History (9)

Changed May 24, 2012 01:11PM UTC by dmethvin comment:1

component: unfiledmanipulation
milestone: None1.8
priority: undecidedlow
status: newopen
summary: Memory leak in hover?Memory leak in .text(val) setter?

It looks like we may be leaking a documentFragment each time .text(val) is used. Really it shouldn't be necessary to go through as much of the code path as we do there, so I'll mark this for investigation.

Changed June 25, 2012 04:28PM UTC by dmethvin comment:2

owner: → gibson042
status: openassigned

Changed June 26, 2012 06:01PM UTC by gibson042 comment:3

Also: I'm not entirely certain I was able to reproduce this, so I'd really appreciate some confirmation that it's fixed.

Changed June 26, 2012 06:50PM UTC by Richard Gibson comment:4

resolution: → fixed
status: assignedclosed

Clear elements to avoid leaking memory. Close gh-837. Fixes #11809

Changeset: b6d02735e955523adcf88ff92b3bc7ecb144c624

Changed June 26, 2012 08:57PM UTC by dmethvin comment:5

It does seem to eventually collect a bunch of DOM elements, so I guess that's fixed. This whole area needs to be burned to the ground come 2.0 time. :D

Changed January 05, 2013 03:10PM UTC by comment:6

It not fixed in version 1.8.3 (browser chrome 23.0.1271.97 m, windows 7).

STEPS TO REPRODUCE PROBLEM Open in Chrome Open Dev tools, navigate to Timeline, then click memory, select range some seconds. You will see that DOM Node count increment on 2 objects per call .text().

Changed January 05, 2013 03:34PM UTC by dmethvin comment:7

@Sysaninster, I see it creating nodes, but not *leaking* them. Can you post a link to a screen shot showing a leak? Also please use jquery-git.js rather than 1.7.2.

Changed January 06, 2013 10:39AM UTC by comment:8

I've done pull request , where I described of problem:

It code bring leak of memory (test in chrome 23.0.1271.97 m, windows 7). Because every call $('selector').text('any text'), create 2 DOM nodes, but .empty() can't remove they. Code for test (I tested with source from repository and v1.8.3) and result . It pull request fix problem.

Changed November 05, 2013 10:15PM UTC by Chris Antaki comment:9

Fix #11809: Update text without creating DOM nodes. Close gh-1412.

Changeset: fb2e0a0c2864846af701203d3708da5dab3e6ba2