Re: addEventListener / attachEvent and passing 'this' to handler
- From: David Mark <dmark.cinsoft@xxxxxxxxx>
- Date: Tue, 14 Jul 2009 03:34:21 -0700 (PDT)
On Jul 14, 5:32 am, Eric Bednarz <bedn...@xxxxxxxxxxxxxxxxxxx> wrote:
David Mark <dmark.cins...@xxxxxxxxx> writes:
On Jul 12, 8:08 am, Eric Bednarz <bedn...@xxxxxxxxxxxxxxxxxxx> wrote:
Using His Library for the same task, there appear to be no real leaks on
Windows 2000 (memory increases notably but is released when navigating
away from the test page). Well done.
LOL. You mean My Library?
Yes, Your Library. ;-)
Doh! Kidding, of course. It wouldn't surprise me in the least if
*something* leaked in there with IE6. It would surprise me if it is
related to attachListener, so I was interested in your tests.
On XP SP2, on the other hand, every refresh leaks average 3 to 4 MiB
memory, with a peak of 8 MiB (refreshing ~ 20 times total).
I'd wager it is unrelated to my event code, which clearly does not
create circular references involving host objects. I'd like to know
exactly what you tested and how you came to your conclusions.
I knew my test was probably problematic itself, but I used the same one
for three different IE 6 environments, so that was not my primary
concern.
You may be on to something. Just not sure what yet.
What I did was creating a DIV element, appending it to the DOM,
appending a text node and attaching a click event. In that order, in a
loop with 500 iterations, on the window’s load event.
Okay.
Not generating the elements client side made things better (rather
unsurpsisingly).
Well, I find that a bit odd. Did the library play any part in
creating these nodes?
And I used the complete library. I already suspected that this would
matter, too. Kangax recently posted the basic event code and I used that
for an absolute minimum test (correcting the minor error he made). With
this setup, I noticed a much smaller but consistent memory leakage.
The complete library is not going to be a good test case for this. I
was going to suggest the code posted by Kangax.
After some random testing the ugly truth dawned upon me. It is much
worse than I thought. I through all of the test code out and generated
a javascript file with 500 function declarations that just return
false. No function calls, no DOM access, nothing. Using that ~ 18KiB
file, IE6 was consistently leaking ~200KiB on every (re)load of the
page. Unsurprisingly, in further testing this leakage grew with the file
size (hence the obscene amount when using the complete mylib.js).
Yes, I suspected IE6 and XP were to blame. Sounds like the bigger the
script (whatever it holds), the bigger the leak. Pretty bad when MS
can't write a competent browser for their own OS.
The offending system is XP SP2.
Should be locked up. :)
I’ll put a test case for that online tomorrow or so, today is some sort
of anniversary to attend to :-)
I guess I'm slightly less interested now, but it would be nice to
document this particular abomination.
I think I've said it here before, but I would never buy a PC with
Windows installed on it again. I can't believe it took me over a
decade to realize that Microsoft was all marketing.
.
- Follow-Ups:
- References:
- addEventListener / attachEvent and passing 'this' to handler
- From: Erwin Moller
- Re: addEventListener / attachEvent and passing 'this' to handler
- From: Martin Honnen
- Re: addEventListener / attachEvent and passing 'this' to handler
- From: Peter Michaux
- Re: addEventListener / attachEvent and passing 'this' to handler
- From: Eric Bednarz
- Re: addEventListener / attachEvent and passing 'this' to handler
- From: David Mark
- Re: addEventListener / attachEvent and passing 'this' to handler
- From: Eric Bednarz
- addEventListener / attachEvent and passing 'this' to handler
- Prev by Date: Re: Document loaded:how to detect?
- Next by Date: Re: Document loaded:how to detect?
- Previous by thread: Re: addEventListener / attachEvent and passing 'this' to handler
- Next by thread: Re: addEventListener / attachEvent and passing 'this' to handler
- Index(es):
Relevant Pages
|