Bug Tracker

Ticket #4375 (closed bug: invalid)

Opened 5 years ago

Last modified 5 years ago

Memory Leak with plugin and $.data().

Reported by: jaredjbarnes Owned by:
Priority: critical Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: Memory Leak, $.data() Cc:
Blocking: Blocked by:

Description

<html> <body> <div id="test"></div> <script src="jquery.js"></script> <script type="text/javascript">

/*Here is the code that causes leaks. This may be because of the circular reference as described here.

 http://www.ibm.com/developerworks/web/library/wa-memleak/

I was under the impression that the data store could have circular refrences, but this may not be the case. I came to the conclusion that this is because the data is stored on the expando object on the node. This would cause the circular reference problem. */

(function(){

var Class1 = function(node){this.node = node;};

$.fn.custom = function(){

$.data(this, 'leak', new Class1(this));

};

})();

var count = 0; var div = $('#test');

var run = function(){

div.append('<span id="'+count+'">'+(count)+'</span>');

$('#'+count).custom();

var spans = $('span');

if (spans.length > 10){ $.removeData(spans[0]); $(spans[0]).remove(); }

if (count >= 15000){ clearInterval(timer); } count++;

};

var start = function(){ count = 0; timer = setInterval(function(){run();},1);

};

</script> <button onclick="start();">go</button>

</body> </html>

Change History

comment:1 in reply to: ↑ description Changed 5 years ago by jaredjbarnes

Using firefox, and found that the data on $.cache is not being removed through $('#nodeId').remove();.

Still can figure out why.

comment:2 Changed 5 years ago by jaredjbarnes

I have found the the Memory leak stops when using $(node).data() instead of $.data();.

comment:3 Changed 5 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

It would be best to triage this in the forums and narrow down the cause of the problem.

Note: See TracTickets for help on using tickets.