Had a nasty memory leak that was seriously slowing down the browser and eating up a couple megabytes every reload. I was using: $$(''.dyntable'').each(function(elm) { new DynTable(elm) }); To set up my behavior, but discovered that just running: $$(''.dyntable''); Caused the memory leak all by itself. The fix I found for it was to change Element.extend to a noop. Element.extend = function(element) { return element; } Apparently IE has that leak where it can''t recognize these enhanced DOM elements as ready for garbage collection because of this enhancement. FYI: this was on latest IE 6 on WinXP. -joel
Turns out this is causing (at least some) of the problems I have been having with IE bloating. The culprit as far as I can tell is the bind call (anon function & dom element, not too sure why this is a circular reference though) in Element.extend. I have been having a poke around, but I can''t think of a way to stop this unless element.extend keeps a list of all extended elements & does something at the appropriate time to release them. Nick On 5/9/06, Joel Shellman <joel-mS8KwmfSQcZBDgjK7y7TUQ@public.gmane.org> wrote:> > Had a nasty memory leak that was seriously slowing down the browser and > eating up a couple megabytes every reload. I was using: > > $$(''.dyntable'').each(function(elm) { new DynTable(elm) }); > > To set up my behavior, but discovered that just running: > > $$(''.dyntable''); > > Caused the memory leak all by itself. > > The fix I found for it was to change Element.extend to a noop. > > Element.extend = function(element) { > return element; > } > > Apparently IE has that leak where it can''t recognize these enhanced DOM > elements as ready for garbage collection because of this enhancement. > > FYI: this was on latest IE 6 on WinXP. > > -joel > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
OK, I have a solution that appears to work for me, tested on firefox & IE. Basically here is the crux of it for those that need it nowish, I will put it on trac when I get the time: Element.extend = function(element) { if (!element) return; if (!element._extendedMethods) element._extendedMethods = {} if (!element._extended && element.tagName && element != window) { var methods = Element.Methods; for (property in methods) { if (typeof methods[property] == ''function'') element[property] = Element.callExtended(property); } } element._extended = true; return element; } Element.callExtended = function(property) { return new Function("args = $A([this]).zip($A(arguments)).flatten(); return Element.Methods."+property+".apply(this, args)"); } Such a small change for the amount of hair I must have lost. ** If anyone can come up with a better alternative to the line: args = $A([this]).zip($A(arguments)).flatten(); i.e. without needing to use flatten, let me know. On 5/9/06, nick hemsley <lists.nick.hems-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Turns out this is causing (at least some) of the problems I have been > having with IE bloating. > > The culprit as far as I can tell is the bind call (anon function & dom > element, not too sure why this is a circular reference though) in > Element.extend. I have been having a poke around, but I can''t think of a > way to stop this unless element.extend keeps a list of all extended > elements & does something at the appropriate time to release them. > > Nick > > > > On 5/9/06, Joel Shellman <joel-mS8KwmfSQcZBDgjK7y7TUQ@public.gmane.org> wrote: > > > > Had a nasty memory leak that was seriously slowing down the browser and > > eating up a couple megabytes every reload. I was using: > > > > $$(''.dyntable'').each(function(elm) { new DynTable(elm) }); > > > > To set up my behavior, but discovered that just running: > > > > $$(''.dyntable''); > > > > Caused the memory leak all by itself. > > > > The fix I found for it was to change Element.extend to a noop. > > > > Element.extend = function(element) { > > return element; > > } > > > > Apparently IE has that leak where it can''t recognize these enhanced DOM > > elements as ready for garbage collection because of this enhancement. > > > > FYI: this was on latest IE 6 on WinXP. > > > > -joel > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Slightly nicer: Element.extend = function(element) { if (!element) return; if (!element._extendedMethods) element._extendedMethods = {} if (!element._extended && element.tagName && element != window) { var methods = Element.Methods; for (property in methods) { if (typeof methods[property] == ''function'') element[property] = Element.callExtended(property); } } element._extended = true; return element; } Element.callExtended = function(property) { return new Function("var args = $A([this]).concat($A(arguments)); return Element.Methods."+property+".apply(this, args)"); } _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 5/10/06, nick hemsley <lists.nick.hems-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> for (property in methods) {for (var property in methods) { ensures that you''re working with a locally-scoped property variable. The way it''s written, if window.property existed, then you just clobbered it. Todd
Disclaimer: Im still getting used to dynamic scoping. & Javascript as well. Which part clobbers window.property? If this _is_ the case, then suiltably unique name would be a temporary, but if you are talking about the for() loop itself, that is unchanged from the original source... actually looking at the latest svn, Element.extend appears to have changed. Too late for me to look at it properly now, but it appears it uses some tricky scope checking to decide what to return. (would this avoid all memory leaks?) ... nice. That mofo is just too fubar for me to come up with. On 5/10/06, Todd Ross <rails-spinoffs-25kFIyuv2iRiLUuM0BA3LQ@public.gmane.org> wrote:> > On 5/10/06, nick hemsley <lists.nick.hems-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > for (property in methods) { > > for (var property in methods) { > > ensures that you''re working with a locally-scoped property variable. > The way it''s written, if window.property existed, then you just > clobbered it. > > Todd > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
OK, scrap this, check out the latest in svn. this issue got raised in trac: http://dev.rubyonrails.org/ticket/4465 On 5/11/06, nick hemsley <lists.nick.hems-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Disclaimer: Im still getting used to dynamic scoping. & Javascript as > well. > > Which part clobbers window.property? If this _is_ the case, then suiltably > unique name would be a temporary, but if you are talking about the for() > loop itself, that is unchanged from the original source... actually looking > at the latest svn, Element.extend appears to have changed. Too late for me > to look at it properly now, but it appears it uses some tricky scope > checking to decide what to return. (would this avoid all memory leaks?) ... > nice. That mofo is just too fubar for me to come up with. > > > > On 5/10/06, Todd Ross <rails-spinoffs-25kFIyuv2iRiLUuM0BA3LQ@public.gmane.org> wrote: > > > > On 5/10/06, nick hemsley <lists.nick.hems-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > for (property in methods) { > > > > for (var property in methods) { > > > > ensures that you''re working with a locally-scoped property variable. > > The way it''s written, if window.property existed, then you just > > clobbered it. > > > > Todd > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Hey Nick, This was checked into svn on 29th March... Are you using the library version that was written much before that? If not, then this might still not address the problems. Thoughts? -Mandy. -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of nick hemsley Sent: Thursday, May 11, 2006 8:24 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] prototype: leak with Element.extend OK, scrap this, check out the latest in svn. this issue got raised in trac: http://dev.rubyonrails.org/ticket/4465 On 5/11/06, nick hemsley < lists.nick.hems-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: Disclaimer: Im still getting used to dynamic scoping. & Javascript as well. Which part clobbers window.property? If this _is_ the case, then suiltably unique name would be a temporary, but if you are talking about the for() loop itself, that is unchanged from the original source... actually looking at the latest svn, Element.extend appears to have changed. Too late for me to look at it properly now, but it appears it uses some tricky scope checking to decide what to return. (would this avoid all memory leaks?) ... nice. That mofo is just too fubar for me to come up with. On 5/10/06, Todd Ross < <mailto:rails-spinoffs-25kFIyuv2iRiLUuM0BA3LQ@public.gmane.org> rails-spinoffs-25kFIyuv2iRiLUuM0BA3LQ@public.gmane.org> wrote: On 5/10/06, nick hemsley < lists.nick.hems-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> for (property in methods) {for (var property in methods) { ensures that you''re working with a locally-scoped property variable. The way it''s written, if window.property existed, then you just clobbered it. Todd _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs <http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs> _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Hello, I was just wondering if anyone has created a smooth accordion feature like: http://moofx.mad4milk.net/ using scriptaculous? I''ve seen the current accordion here: http://wiki.script.aculo.us/scriptaculous/show/accordion+feature but, It seems to be real jumpy. Any information would be greatly appreciated. Thanks. Joe _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Hey. I have one but it''s not perfect yet. Attached in a zip. -Rob Joe Hudson wrote:> Hello, I was just wondering if anyone has created a smooth accordion > feature like: http://moofx.mad4milk.net/ using scriptaculous? > > > > I’ve seen the current accordion here: > http://wiki.script.aculo.us/scriptaculous/show/accordion+feature > but, It seems to be real jumpy. Any information would be greatly > appreciated. > > > > Thanks. > > > > Joe > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Thanks very much, Rob. Joe> -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs- > bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Robin Haswell > Sent: Thursday, May 11, 2006 4:38 AM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] anyone have a good accordion component? > > Hey. I have one but it''s not perfect yet. Attached in a zip. > > -Rob > > Joe Hudson wrote: > > Hello, I was just wondering if anyone has created a smooth accordion > > feature like: http://moofx.mad4milk.net/ using scriptaculous? > > > > > > > > I''ve seen the current accordion here: > > http://wiki.script.aculo.us/scriptaculous/show/accordion+feature > > but, It seems to be real jumpy. Any information would be greatly > > appreciated. > > > > > > > > Thanks. > > > > > > > > Joe > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I checked it out from svn yesterday. bit of a pain as it needs rake to build the prototype.js file. if anyone wants it, let me know. On 5/11/06, Maninder, Singh <mandiv-W2hqgAdRMsX2eFz/2MeuCQ@public.gmane.org> wrote:> > > Hey Nick, > > This was checked into svn on 29th March... > > Are you using the library version that was written much before that? > > If not, then this might still not address the problems. > > Thoughts? > > -Mandy. > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On > Behalf Of nick hemsley > Sent: Thursday, May 11, 2006 8:24 AM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] prototype: leak with Element.extend > > OK, scrap this, check out the latest in svn. this issue got raised in trac: > http://dev.rubyonrails.org/ticket/4465 > > > On 5/11/06, nick hemsley <lists.nick.hems-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Disclaimer: Im still getting used to dynamic scoping. & Javascript as > well. > > > > Which part clobbers window.property? If this _is_ the case, then suiltably > unique name would be a temporary, but if you are talking about the for() > loop itself, that is unchanged from the original source... actually looking > at the latest svn, Element.extend appears to have changed. Too late for me > to look at it properly now, but it appears it uses some tricky scope > checking to decide what to return. (would this avoid all memory leaks?) ... > nice. That mofo is just too fubar for me to come up with. > > > > > > > > > > On 5/10/06, Todd Ross < rails-spinoffs-25kFIyuv2iRiLUuM0BA3LQ@public.gmane.org> wrote: > > > On 5/10/06, nick hemsley <lists.nick.hems-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > for (property in methods) { > > > > > > for (var property in methods) { > > > > > > ensures that you''re working with a locally-scoped property variable. > > > The way it''s written, if window.property existed, then you just > > > clobbered it. > > > > > > Todd > > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >
And yes, it fixed the memory problems I was having. (ie still leaks a little, but not much) On 5/12/06, nick hemsley <lists.nick.hems-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I checked it out from svn yesterday. bit of a pain as it needs rake to > build the prototype.js file. if anyone wants it, let me know. > > On 5/11/06, Maninder, Singh <mandiv-W2hqgAdRMsX2eFz/2MeuCQ@public.gmane.org> wrote: > > > > > > Hey Nick, > > > > This was checked into svn on 29th March... > > > > Are you using the library version that was written much before that? > > > > If not, then this might still not address the problems. > > > > Thoughts? > > > > -Mandy. > > > > > > -----Original Message----- > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On > > Behalf Of nick hemsley > > Sent: Thursday, May 11, 2006 8:24 AM > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > Subject: Re: [Rails-spinoffs] prototype: leak with Element.extend > > > > OK, scrap this, check out the latest in svn. this issue got raised in trac: > > http://dev.rubyonrails.org/ticket/4465 > > > > > > On 5/11/06, nick hemsley <lists.nick.hems-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Disclaimer: Im still getting used to dynamic scoping. & Javascript as > > well. > > > > > > Which part clobbers window.property? If this _is_ the case, then suiltably > > unique name would be a temporary, but if you are talking about the for() > > loop itself, that is unchanged from the original source... actually looking > > at the latest svn, Element.extend appears to have changed. Too late for me > > to look at it properly now, but it appears it uses some tricky scope > > checking to decide what to return. (would this avoid all memory leaks?) ... > > nice. That mofo is just too fubar for me to come up with. > > > > > > > > > > > > > > > On 5/10/06, Todd Ross < rails-spinoffs-25kFIyuv2iRiLUuM0BA3LQ@public.gmane.org> wrote: > > > > On 5/10/06, nick hemsley <lists.nick.hems-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > for (property in methods) { > > > > > > > > for (var property in methods) { > > > > > > > > ensures that you''re working with a locally-scoped property variable. > > > > The way it''s written, if window.property existed, then you just > > > > clobbered it. > > > > > > > > Todd > > > > _______________________________________________ > > > > Rails-spinoffs mailing list > > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > >