[jQuery] Re: How to handle Pseudo leak in IE?

2007-05-22 Thread Jacky

Some progress...
by using a garbage collection bin (a dummy div to appendChild and then empty
the innerHTML), the DOM usage is stable now. Code:


jQuery.fn.discard = function(){
   var garbageBin = document.getElementById('IELeakGarbageBin');
   if (!garbageBin) {
   garbageBin = document.createElement('DIV');
   garbageBin.id = 'IELeakGarbageBin';
   //garbageBin.style.display = 'none';
   document.body.appendChild(garbageBin);
   }

   this
   .unbind() //unbind all handlers
   .each(function(){ // move the element to the garbage bin
   garbageBin.appendChild(this);
   garbageBin.innerHTML = '';
   });

   garbageBin = null;
}

Usage: e.g. $(testtbody*).discard();

But there are stills some memory keep increasing in IE when those addRows
and deleteRows repeat again and again. Not knowing why.

On 5/22/07, Jacky [EMAIL PROTECTED] wrote:


I have some problem in creating the ticket. It always timeout when I
submitting... I will try later.

Anyway, here is an example about it.
Load it in IESieve , cilck refresh rows or set interval and watch the
memory and dom usage.

html
head
titleTest Mem Leak in IE6/title
script type=text/javascript src=jquery-1.1.2.js/script
script type=text/javascript
var datas = [
[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5]
];


$(document).ready(function(){
$(#remove).click(removeAllRows);
$(#refresh).click(refreshRows);
$(#interval).click(startRefresh);

});

function startRefresh(){
var interval = setInterval(refreshRows,5*1000);
}

function refreshRows(){
removeAllRows();
for(var i=0; idatas.length; i++){
var tr = document.createElement(tr);
for(var j=0; jdatas[i].length; j++){
var td = document.createElement(td);
var d = datas[i][j]*Math.floor(Math.random
()*100+1);
td.innerHTML =
a href='#' onclick='return
false;'+d+/a +
input type='button'
onclick='buttonClick(this)' value='+datas[i][j]+'/;
$(tr).append(td);
td = null;
d = null;
}
var tb = $(#testtbody).append(tr);
}
}

function removeAllRows(){
var tb = $(#testtbody)
.find(*).unbind().end()
.html();
}

function buttonClick(obj){
obj.value = 'btn';
}


/script
/head
body
table id=test border=1
thead
tr
thth1/th
thth2/th
thth3/th
thth4/th
thth5/th
/tr
/thead
tbody

/tbody
/table
input type=button value=remove all rows id=remove/
input type=button value=refresh all rows id=refresh/
input type=button value=start interval id=interval/

/body

/html

--
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

On 5/21/07, Brandon Aaron [EMAIL PROTECTED] wrote:


 If you could create a ticket and a test case for this it would help a
 lot! I believe I could find some time to investigate it in detail
 soon.

 --
 Brandon Aaron

 On 5/21/07, Jacky  [EMAIL PROTECTED] wrote:
  Hi all,
 
  I'm dealing with the IE memory problem.
  There is an IE leak called 'pseudo leak', where removeChild() is not
 really
  removing child from memory.
  It is pseudo because it would be cleared after refresh.
  (some detail:
  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/IETechCol/dnwebgen/ie_leak_patterns.asp

  )
 
  However, my app is not page-driven, it would stay on same page and
  refreshing ajax call, refreshing table rows, etc. So the memory would
 just
  keep raising by the pseudo leak.
 
  It is said in some site that by setting innerHTML =  would prevent
 the
  leak.
  So I try to do something like:
 
  $(tbody)
 .find(*).unbind().end() //unbinding all handler to prevent
 another
  closure leak
 .find(td,tr).html().remove().end() //setting html
  = and remove itself
 .html(); //setting tbody html to empty
 
  I use IESieve ( http://home.wanadoo.nl/jsrosman/ ) to check
  for the the dom object creation but it just keep increasing.
  Is there anyone try to tackle this 'leak' before?
  --
  Best Regards,
  Jacky
  網絡暴民 http://jacky.seezone.net
 






--
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net


[jQuery] Re: How to handle Pseudo leak in IE?

2007-05-22 Thread Brandon Aaron


One way around this in your app and apps like yours is to invoke the
IE garbage collector by calling the GarbageCollect function. You would
want to do this every so often are important clicks/exchanging.
Calling this method should release any memory that IE would normally
release on refresh.

Just call it like this:

GarbageCollect();

Hope that helps. In the future I think it migh be nice to have a
garbageBin type plugin for applications like yours.

--
Brandon Aaron

On 5/22/07, Jacky [EMAIL PROTECTED] wrote:

Some progress...
by using a garbage collection bin (a dummy div to appendChild and then empty
the innerHTML), the DOM usage is stable now. Code:


jQuery.fn.discard = function(){
var garbageBin = document.getElementById ('IELeakGarbageBin');
if (!garbageBin) {
garbageBin = document.createElement('DIV');
garbageBin.id = 'IELeakGarbageBin';
//garbageBin.style.display = 'none';
document.body.appendChild(garbageBin);
}

this
.unbind() //unbind all handlers
.each(function(){ // move the element to the garbage bin
garbageBin.appendChild (this);
garbageBin.innerHTML = '';
});

garbageBin = null;
}

Usage: e.g. $(testtbody*).discard();

But there are stills some memory keep increasing in IE when those addRows
and deleteRows repeat again and again. Not knowing why.


On 5/22/07, Jacky [EMAIL PROTECTED] wrote:
 I have some problem in creating the ticket. It always timeout when I
submitting... I will try later.

 Anyway, here is an example about it.
 Load it in IESieve , cilck refresh rows or set interval and watch the
memory and dom usage.

 html
 head
 titleTest Mem Leak in IE6/title
 script type=text/javascript src=jquery-1.1.2.js/script
 script type=text/javascript
 var datas = [
 [1,2,3,4,5],
 [1,2,3,4,5],
 [1,2,3,4,5],
 [1,2,3,4,5],
 [1,2,3,4,5],
 [1,2,3,4,5]
 ];


 $(document).ready(function(){
 $(#remove).click(removeAllRows);
 $(#refresh).click(refreshRows);
 $(#interval).click(startRefresh);

 });

 function startRefresh(){
 var interval =
setInterval(refreshRows,5*1000);
 }

 function refreshRows(){
 removeAllRows();
 for(var i=0; idatas.length; i++){
 var tr = document.createElement (tr);
 for(var j=0; jdatas[i].length; j++){
 var td = document.createElement(td);
 var d =
datas[i][j]*Math.floor(Math.random()*100+1);
 td.innerHTML =
 a href='#' onclick='return
false;'+d+/a +
 input type='button'
onclick='buttonClick(this)' value='+datas[i][j]+'/;
 $(tr).append(td);
 td = null;
 d = null;
 }
 var tb = $(#testtbody).append(tr);
 }
 }

 function removeAllRows(){
 var tb = $(#testtbody)
 .find(*).unbind().end()
 .html();
 }

 function buttonClick(obj){
 obj.value = 'btn';
 }


 /script
 /head
 body
 table id=test border=1
 thead
 tr
 thth1/th
 thth2/th
 thth3/th
 thth4/th
 thth5/th
 /tr
 /thead
 tbody

 /tbody
 /table
 input type=button value=remove all rows id=remove/
 input type=button value=refresh all rows id=refresh/
 input type=button value=start interval id=interval/

 /body

 /html

 --
 Best Regards,
 Jacky
 網絡暴民 http://jacky.seezone.net



 On 5/21/07, Brandon Aaron  [EMAIL PROTECTED] wrote:
 
  If you could create a ticket and a test case for this it would help a
  lot! I believe I could find some time to investigate it in detail
  soon.
 
  --
  Brandon Aaron
 
  On 5/21/07, Jacky  [EMAIL PROTECTED] wrote:
   Hi all,
  
   I'm dealing with the IE memory problem.
   There is an IE leak called 'pseudo leak', where removeChild() is not
really
   removing child from memory.
   It is pseudo because it would be cleared after refresh.
   (some detail:
  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/IETechCol/dnwebgen/ie_leak_patterns.asp
   )
  
   However, my app is not page-driven, it would stay on same page and
   refreshing ajax call, refreshing table rows, etc. So the memory would
just
   keep raising by the pseudo leak.
  
   It is said in some site that by setting innerHTML =  would prevent
the
   leak.
   So I try 

[jQuery] Re: How to handle Pseudo leak in IE?

2007-05-21 Thread Brandon Aaron


If you could create a ticket and a test case for this it would help a
lot! I believe I could find some time to investigate it in detail
soon.

--
Brandon Aaron

On 5/21/07, Jacky [EMAIL PROTECTED] wrote:

Hi all,

I'm dealing with the IE memory problem.
There is an IE leak called 'pseudo leak', where removeChild() is not really
removing child from memory.
It is pseudo because it would be cleared after refresh.
(some detail:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/IETechCol/dnwebgen/ie_leak_patterns.asp
)

However, my app is not page-driven, it would stay on same page and
refreshing ajax call, refreshing table rows, etc. So the memory would just
keep raising by the pseudo leak.

It is said in some site that by setting innerHTML =  would prevent the
leak.
So I try to do something like:

$(tbody)
   .find(*).unbind().end() //unbinding all handler to prevent another
closure leak
   .find(td,tr).html().remove().end() //setting html
= and remove itself
   .html(); //setting tbody html to empty

I use IESieve (http://home.wanadoo.nl/jsrosman/ ) to check
for the the dom object creation but it just keep increasing.
Is there anyone try to tackle this 'leak' before?
--
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net



[jQuery] Re: How to handle Pseudo leak in IE?

2007-05-21 Thread Jacky

I have some problem in creating the ticket. It always timeout when I
submitting... I will try later.

Anyway, here is an example about it.
Load it in IESieve , cilck refresh rows or set interval and watch the memory
and dom usage.

html
   head
   titleTest Mem Leak in IE6/title
   script type=text/javascript src=jquery-1.1.2.js/script
   script type=text/javascript
   var datas = [
   [1,2,3,4,5],
   [1,2,3,4,5],
   [1,2,3,4,5],
   [1,2,3,4,5],
   [1,2,3,4,5],
   [1,2,3,4,5]
   ];


   $(document).ready(function(){
   $(#remove).click(removeAllRows);
   $(#refresh).click(refreshRows);
   $(#interval).click(startRefresh);

   });

   function startRefresh(){
   var interval = setInterval(refreshRows,5*1000);
   }

   function refreshRows(){
   removeAllRows();
   for(var i=0; idatas.length; i++){
   var tr = document.createElement(tr);
   for(var j=0; jdatas[i].length; j++){
   var td = document.createElement(td);
   var d = datas[i][j]*Math.floor(Math.random()*100+1);
   td.innerHTML =
   a href='#' onclick='return false;'+d+/a
+
   input type='button'
onclick='buttonClick(this)' value='+datas[i][j]+'/;
   $(tr).append(td);
   td = null;
   d = null;
   }
   var tb = $(#testtbody).append(tr);
   }
   }

   function removeAllRows(){
   var tb = $(#testtbody)
   .find(*).unbind().end()
   .html();
   }

   function buttonClick(obj){
   obj.value = 'btn';
   }


   /script
   /head
   body
   table id=test border=1
   thead
   tr
   thth1/th
   thth2/th
   thth3/th
   thth4/th
   thth5/th
   /tr
   /thead
   tbody

   /tbody
   /table
   input type=button value=remove all rows id=remove/
   input type=button value=refresh all rows id=refresh/
   input type=button value=start interval id=interval/

   /body

/html

--
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

On 5/21/07, Brandon Aaron [EMAIL PROTECTED] wrote:



If you could create a ticket and a test case for this it would help a
lot! I believe I could find some time to investigate it in detail
soon.

--
Brandon Aaron

On 5/21/07, Jacky [EMAIL PROTECTED] wrote:
 Hi all,

 I'm dealing with the IE memory problem.
 There is an IE leak called 'pseudo leak', where removeChild() is not
really
 removing child from memory.
 It is pseudo because it would be cleared after refresh.
 (some detail:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/IETechCol/dnwebgen/ie_leak_patterns.asp
 )

 However, my app is not page-driven, it would stay on same page and
 refreshing ajax call, refreshing table rows, etc. So the memory would
just
 keep raising by the pseudo leak.

 It is said in some site that by setting innerHTML =  would prevent the
 leak.
 So I try to do something like:

 $(tbody)
.find(*).unbind().end() //unbinding all handler to prevent another
 closure leak
.find(td,tr).html().remove().end() //setting html
 = and remove itself
.html(); //setting tbody html to empty

 I use IESieve (http://home.wanadoo.nl/jsrosman/ ) to check
 for the the dom object creation but it just keep increasing.
 Is there anyone try to tackle this 'leak' before?
 --
 Best Regards,
 Jacky
 網絡暴民 http://jacky.seezone.net