Skip to main content

Bug Tracker

Side navigation

#4375 closed bug (invalid)

Opened March 18, 2009 03:29PM UTC

Closed October 14, 2009 01:37AM UTC

Last modified January 07, 2010 06:54AM UTC

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:
Blocked by: Blocking:



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

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.



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>');


var spans = $('span');

if (spans.length > 10){




if (count >= 15000){





var start = function(){

count = 0;

timer = setInterval(function(){run();},1);



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



Attachments (0)
Change History (3)

Changed March 18, 2009 05:18PM UTC by jaredjbarnes comment:1

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

Still can figure out why.

Changed March 18, 2009 06:32PM UTC by jaredjbarnes comment:2

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

Changed October 14, 2009 01:37AM UTC by dmethvin comment:3

resolution: → invalid
status: newclosed

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