Skip to main content

Search and Top Navigation

#4408 closed bug (duplicate)

Opened March 27, 2009 08:03AM UTC

Closed March 27, 2009 11:40PM UTC

ui.widget factory causes memory leak?

Reported by: easonkie Owned by:
Priority: major Milestone:
Component: ui.core Version: 1.7.1
Keywords: memory leak Cc:
Blocked by: Blocking:
Description

Hi all, I just started using the ui.widget factory and I found it might cause memory leak . I created the test code as below, and either in IE6 or FF3 the memory will not be released unless I refresh the page. Anyone knows what's going on? Thanks.

var repository = [];

function create()

{

for(var i=0;i<5;i++)

{

for(var j=0;j<20;j++)

{

var obj = $("<div/>").css('left',i*150).css('top',j*40).appendTo(document.body).testor();

}

}

}

function destroy()

{

for(var i=0;i<repository.length;i++)

{

repository[i].testor('destroy');

delete repository[i];

repository[i] = null;

}

repository.splice(0,repository.length);

}

$(function() {

$("<button/>").attr('value','start').css('position','absolute').css('left',800).css('top',800).css('height',20).css('width','80').appendTo(document.body).click(function(){

for(var i=0;i<100;i++)

{

create();

destroy();

}

});

Attachments (0)
Change History (4)

Changed March 27, 2009 08:16AM UTC by easonkie comment:1

Before I trigger the code , the mem usage of IE is 33,040KB and after the code executed it turns to more than 160,000KB. And it won't be released until i click 'Refresh'.

Changed March 27, 2009 08:21AM UTC by easonkie comment:2

here is the condition in FF3:

mem usage before trigger the code:50,000K

mem usage after trigger the code :190,464K

and it will not be released until I refresh the page either.

Changed March 27, 2009 08:53AM UTC by easonkie comment:3

sorry , i pasted the wrong code just now . here is the new snippet:

var repository = [];

function create()

{

for(var i=0;i<5;i++)

{

for(var j=0;j<20;j++)

{

repository.push(

$("div/>").css('left',i*150).css('top',j*40).appendTo(document.body).testor());

}

}

}

function destroy()

{

for(var i=0;i<repository.length;i++){

repository[i].testor('destroy'); delete repository[i]; repository[i] = null;

}

repository.splice(0,repository.length);

}

$(function() { $("<button/>").attr('value','start').css('position','absolute').css('left',800).css('top',800).css('height',20).css('width','80').appendTo(document.body).click(function(){ for(var i=0;i<100;i++) {

create();

destroy(); } });

Changed March 27, 2009 11:40PM UTC by scottgonzalez comment:4

resolution: → duplicate
status: newclosed

Duplicate of #4188.