Re: [jQuery] Memory leak

2006-12-12 Thread Ethan Hannagan

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 /
 titleIE Memory Leak/title
 /head
 body

 button id=reloadreload/buttonbr
 button id=bindbind/buttonbrbr

 button id=reloadnbindreload  bind/buttonbrbr

 button id=cleanclean!/buttonbr

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

 $(#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/


Re: [jQuery] Memory leak

2006-12-12 Thread Ethan Hannagan

The purpose of the bigString expando is just to create a huge object and make
it easier to spot that there's a memory leak.


Citrus wrote:
 
 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 /
 titleIE Memory Leak/title
 /head
 body

 button id=reloadreload/buttonbr
 button id=bindbind/buttonbrbr

 button id=reloadnbindreload  bind/buttonbrbr

 button id=cleanclean!/buttonbr

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

 $(#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/
 
 

-- 
View this message in context: 
http://www.nabble.com/Memory-leak-tf2792655.html#a7837984
Sent from the JQuery mailing list archive at Nabble.com.


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


Re: [jQuery] Memory leak

2006-12-12 Thread Ethan Hannagan

Yes, but when I click on the 'clean' button, Im unbinding and clearing out
the event, to avoid memory leak, but somehow the leak is still there.

When I click in the clean button, this code gets executed...

var p = $(#container).find(p);
p.unbind();
p.get(0).onclick = null;

$(#container).html();

But I don't know what else I need to clear out to get rid of the memory
leak.


Klaus Hartl wrote:
 
 Ethan Hannagan schrieb:
 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.
 
 I think it's because you have a circular reference here, created by the 
 closure:
 
 function bind() {
  var p = $(this).find(p);
  p.click(function(){});
 }
 
 
 -- Klaus
 
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/Memory-leak-tf2792655.html#a7838041
Sent from the JQuery mailing list archive at Nabble.com.


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


[jQuery] Memory leak

2006-12-11 Thread Ethan Hannagan

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 /
titleIE Memory Leak/title
/head
body

button id=reloadreload/buttonbr
button id=bindbind/buttonbrbr

button id=reloadnbindreload  bind/buttonbrbr

button id=cleanclean!/buttonbr

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

$(#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/