[thelist] JS memory leak detection?

VOLKAN ÖZÇELİK volkan.ozcelik at gmail.com
Mon Oct 24 01:53:35 CDT 2005


> >
> > Just a note about that code you have there: The unload event isn't reliable
> > for a number of reasons. Especially not in op. I suggest using
> > onbeforeunload instead.
>

Here are compatibility results for onbeforeunload:

Opera 8 -> *it does not work*
IE -> works okay
Moz -> works okay
Saf -> not tested

So voting for onbeforeunload against onunload because Opera does not
support ununload is kinda mistake. Because Opera does not support
onbeforeunload at all.

Here is what ppk says about Opera' onunload:

"
In Opera load and unload do not fire when the user uses Back or
Forward to enter or leave a page, or when the user closes the window.
"
... onload support of opera is similar. again PPK says:

"
Opera itself says this is the correct way to handle onload. Although
this may be true, it will certainly cause compatibility problems.
"

Here is another quote from someone else:

"IE4+/Win, Mozilla 1.7a+, Netscape 7.2+, and Firefox support onbeforeunload"

At least Safari fully supports onunload event. I am not sure whether
it supports onbeforeunload, and if it does whether it supports it
correctly.

Having seen that Opera does not have the memory leakage problem at
all, the onunload fix is basically for ie and moz.

In short, I think I'll stick with onunload.

Or I may use a switch like:

var g_bul_fired=false;
window.onbeforeunload=function(evt){
  g_bul_fired=true;
  ... cleanup ...
};
window.onunload=function(evt){
  if(!g_bul_fired){
    ... cleanup ...
  }
};

Cheers,
--
Volkan Ozcelik
+>Yep! I'm blogging! : http://www.volkanozcelik.com/volkanozcelik/blog/
+> My projects/studies/trials/errors : http://www.sarmal.com/



More information about the thelist mailing list