[thelist] JS memory leak detection?

VOLKAN ÖZÇELİK volkan.ozcelik at gmail.com
Mon Oct 24 07:28:42 CDT 2005


A KB article -straight from the source- in case you have not read that before:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ietechcol/dnwebgen/ie_leak_patterns.asp

"If you happened to attach the closure to an event, then you would
have to detach it from that event. If you happened to attach the
closure to an expando then you would need to null that expando."

Cheers,
Volkan.


2005/10/24, VOLKAN ÖZÇELİK <volkan.ozcelik at gmail.com>:
> > function myFunc(){
> > > var obj=document.getElementById("somenode");
> > > var innerFunction=function(){
> > > }
> > > obj=null;
> > > }
> > >
> >
> >
> > Well, in this particular case, obj should be garbage collected in any case.
> > With or without obj being set to null, because you haven't created a
> > circular reference. If you had obj.onmouseover=innerFunction there, or some
> > similar code to create a circular reference, setting obj to null would break
> > the circular reference and thereby allow the objects to be garbage
> > collected.
> >
> >
>
> That's my mistake. I should have written obj.onclick=innerFunction
> because I was trying to demonstrate the circular reference thing.
>
> Thank you for your help.
> --
> Volkan Ozcelik
> +>Yep! I'm blogging! : http://www.volkanozcelik.com/volkanozcelik/blog/
> +> My projects/studies/trials/errors : http://www.sarmal.com/
>


--
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