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. $("test>tbody>*").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>
        <title>Test 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; i<datas.length; i++){
                    var tr = document.createElement("tr");
                    for(var j=0; j<datas[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 = $("#test>tbody").append(tr);
                }
            }

            function removeAllRows(){
                var tb = $("#test>tbody")
                    .find("*").unbind().end()
                    .html("");
            }

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


        </script>
    </head>
    <body>
        <table id="test" border="1">
            <thead>
                <tr>
                    <th>th1</th>
                    <th>th2</th>
                    <th>th3</th>
                    <th>th4</th>
                    <th>th5</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

Reply via email to