I think that the reloadandbind call may be creating a closure that you're
not intending.  But, that's just me looking at the code for 5 minutes, I
might not be seeing it straight.

Also, it's a bad idea to stick custom js objects onto DOM objects -
specifically "bigString".  It causes conflicts between IE's two garbage
collectors.  You should create a js object instead that has a DOM element
as a member, and also the custom (bigString) part as a member.

foo = { para: p.get(0), bigString: ... }

Lastly, while I don't know what effect this has, I'd say that you
shouldn't be calling "new Array()" if you don't have to.

I hope that some of this helps.

- Brian


> Thanks for your reply. I downloaded the latest from SVN and built it, but
> I
> still have the same memory leak. Anyhow I still can't figure out where the
> memory leak is, I'm not sure if it's my code or jQuery.
>
>
> Brandon Aaron wrote:
>>
>> Please grab the latest from SVN as it fixes the memory leak in IE.
>>
>> --
>> Brandon Aaron
>>
>> On 12/11/06, Ethan Hannagan <[EMAIL PROTECTED]> wrote:
>>>
>>> Hi,
>>>
>>> Can you help me spot what is causing the memory leak in the following
>>> code?
>>>
>>> If I click "reload", "bind", and "clean" several times, the memory
>>> allocation for IE stays still.
>>> But if I click in the "reload & bind" and then "clean", several times,
>>> the
>>> memory allocation keeps climbing.
>>>
>>> I appreciate any feedback you may have.
>>>
>>> Thanks,
>>> Ethan
>>>
>>> =================================================================
>>> <html>
>>> <head>
>>> <script type="text/javascript" src="jquery-1.0.3.js"></script>
>>> <meta http-equiv="content-type" content="text/html" />
>>> <title>IE Memory Leak</title>
>>> </head>
>>> <body>
>>>
>>> <button id="reload">reload</button><br>
>>> <button id="bind">bind</button><br><br>
>>>
>>> <button id="reloadnbind">reload & bind</button><br><br>
>>>
>>> <button id="clean">clean!</button><br>
>>>
>>> <div id="container" style="border:1px solid red"></div>
>>> <div id="counter" style="border:1px solid green"></div>
>>>
>>> <script type="text/javascript">
>>>   var counter = 1;
>>>
>>>   function reload(callback){
>>>     $("#container").load("template.html", callback);
>>>   }
>>>
>>>   function bind(){
>>>     var p = $(this).find("p");
>>>     p.click(function(){});
>>>     p.get(0).bigString = new Array(1000).join(new
>>> Array(1000).join("XXXXX"));
>>>
>>>     $("#counter").html(counter++);
>>>   }
>>>
>>>   $("#reload").click(reload);
>>>   $("#bind").click(bind);
>>>   $("#reloadnbind").click(function(){
>>>     reload(bind);
>>>   });
>>>
>>>   $("#clean").click(function(){
>>>     var p = $("#container").find("p");
>>>     p.unbind();
>>>     p.get(0).onclick = null;
>>>
>>>     $("#container").html("");
>>>   });
>>> </script>
>>> </body>
>>> </html>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Memory-leak-tf2792655.html#a7791251
>>> Sent from the JQuery mailing list archive at Nabble.com.
>>>
>>>
>>> _______________________________________________
>>> jQuery mailing list
>>> discuss@jquery.com
>>> http://jquery.com/discuss/
>>>
>>
>> _______________________________________________
>> jQuery mailing list
>> discuss@jquery.com
>> http://jquery.com/discuss/
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Memory-leak-tf2792655.html#a7836682
> Sent from the JQuery mailing list archive at Nabble.com.
>
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>



_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to