#11809 closed bug (fixed)
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: |
Description
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?
STEPS TO REPRODUCE PROBLEM Open http://jsfiddle.net/A367T/4/ 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?
Change History (9)
comment:1 Changed 11 years ago by
Component: | unfiled → manipulation |
---|---|
Milestone: | None → 1.8 |
Priority: | undecided → low |
Status: | new → open |
Summary: | Memory leak in hover? → Memory leak in .text(val) setter? |
comment:2 Changed 11 years ago by
Owner: | set to gibson042 |
---|---|
Status: | open → assigned |
comment:3 Changed 11 years ago by
https://github.com/jquery/jquery/pull/837
Also: I'm not entirely certain I was able to reproduce this, so I'd really appreciate some confirmation that it's fixed.
comment:4 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Clear elements to avoid leaking memory. Close gh-837. Fixes #11809
Changeset: b6d02735e955523adcf88ff92b3bc7ecb144c624
comment:5 Changed 11 years ago by
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
comment:6 Changed 10 years ago by
It not fixed in version 1.8.3 (browser chrome 23.0.1271.97 m, windows 7).
STEPS TO REPRODUCE PROBLEM Open http://jsfiddle.net/3RSWf/ 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().
comment:7 Changed 10 years ago by
@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.
comment:8 Changed 10 years ago by
I've done pull request https://github.com/jquery/jquery/pull/1113 , 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 http://jsfiddle.net/3RSWf/ (I tested with source from repository and v1.8.3) and result http://my.jetscreenshot.com/7184/20130106-r5yo-219kb . It pull request fix problem.
comment:9 Changed 9 years ago by
Fix #11809: Update text without creating DOM nodes. Close gh-1412.
Changeset: fb2e0a0c2864846af701203d3708da5dab3e6ba2
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.