Bug Tracker

Ticket #11809 (closed bug: fixed)

Opened 2 years ago

Last modified 12 months ago

Memory leak in .text(val) setter?

Reported by: jase.williams@… Owned by: gibson042
Priority: low Milestone: 1.8
Component: manipulation Version: 1.7.2
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 Changed 2 years ago by dmethvin

  • Priority changed from undecided to low
  • Status changed from new to open
  • Summary changed from Memory leak in hover? to Memory leak in .text(val) setter?
  • Component changed from unfiled to manipulation
  • Milestone changed from None to 1.8

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.

comment:2 Changed 2 years ago by dmethvin

  • Owner set to gibson042
  • Status changed from open to assigned

comment:3 Changed 2 years ago by gibson042

 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 2 years ago by Richard Gibson

  • Status changed from assigned to closed
  • Resolution set to fixed

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

Changeset: b6d02735e955523adcf88ff92b3bc7ecb144c624

comment:5 Changed 2 years ago by dmethvin

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 22 months ago by Sysaninster@…

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 22 months ago by dmethvin

@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 22 months ago by Sysaninster@…

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 12 months ago by Chris Antaki

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

Changeset: fb2e0a0c2864846af701203d3708da5dab3e6ba2

Note: See TracTickets for help on using tickets.