.

Saturday, October 07, 2006

Don't Panic! Leak Monitor Does not Always Show Actual Leaks #

Mozilla Leak Monitor extension says that sardalya's _.chain method leaks if you decide to attach the event explicitly bypassing the EventRegistry.

In the core of sardalya , at times, I explicitly bypass EventRegistry attachment if (and only if) I am 100% sure that the code would not leak (no closures, no expando properties etc...).

The author of the plugin also confirms my action:
Some of these leaks are things that are clearly bugs in the extension (such as registering observers with the observer service forever) and some are things that arguably shouldn't leak (at varying argument strengths).
Although some of those leaks may be real. Most of those leaks are due to a bug in the extension (or FF1.5 or both).

Currently there is a lot of buzz around in blogs and forums telling;
... and also XYZ Framework Leaks, I've installed the Firefox Leak Monitor plugin and oh my goodness; every single site I visit is leaking! gmail is leaking, dojo is leaking, prototype is leaking.

Hey look! sardalya leaks as well.
I am in need to write this blog post; because I've received a pile of e-mails telling that the current version of sardalya has leaks in it. Thank you everyone for your feedback. I very much appreciate them and use your comments and suggestions as a means to improve, enhance and re-shape sardalya.

...Coming back to the leak issue. Well I (think that I) have adequate knowledge on what causes a JavaScript memory leak, in what circumstances the memory leaks etc... I've even written an article about it. And I am pretty (99.999%) sure that the former version of sardalya does not leak.

To keep the long story short I've converted expressions like

_.chain(document,"mousemove",
this._onMouseMove,true);


to

_.chain(document,"mousemove",
this._onMouseMove);


in the current version of sardalya.

I think this is a better approach (whether there is an actual leak or not) because
  • First of all it is a defensive coding practice. Better be safe than sorry.

  • Secondly reclaiming memory as soon as possible in window unload, instead of leaving the decision to the garbage collector will positively affect performance.
There is a caveat though: If there is an excessive amount of event registration going on the page; the internal array that holds pointers to event handlers in the EventRegistry object may increase in size and this will result in a slightly increased amount of memory consumption (a.ka. a pseudo leak)

But I guesstimate that this pseudo leak won't be recognizable in practical situations.

And yes I've released a new version of sardalya (2.2.5). It has some minor fixes and this leak issue implemented.

Labels: , ,


 bu yaziyi sevdin mi?  hemen una ekle!
 


0 Coments


Post a Comment

Links to this post:


Create a Link

<< Home




Recent Posts

RSS

RSS register icon

Other Blogs

Various

Sponsor

Profile Information

Browser I Suggest

Sponsor

Dikkatimi Çekenler