Opened 11 years ago

Closed 11 years ago

#4408 closed bug (duplicate)

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(); } });

Change History (4)

comment:1 Changed 11 years ago by easonkie

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

comment:2 Changed 11 years ago by easonkie

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.

comment:3 Changed 11 years ago by easonkie

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(); } });

comment:4 Changed 11 years ago by Scott González

Resolution: duplicate
Status: newclosed

Duplicate of #4188.

Note: See TracTickets for help on using tickets.