Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.datemas.de!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Is it necessary to explicitly destroy elements? Date: Sat, 16 May 2015 18:09:21 +0200 Organization: PointedEars Software (PES) Lines: 31 Message-ID: <2602320.PcnAOMWr9L@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: solani.org 1431792721 32707 eJwFwYEBwCAIA7CXhqVFzhmg/59gQsjU4aKcl3d5BDwtYWilWJH1b9RMFie+dTJoc9CDzXr9dBCI (16 May 2015 16:12:01 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sat, 16 May 2015 16:12:01 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwYEBwCAIA7CXxEph5wjY/09Y4qCx49B5XC5m2tpD3Ffw2Uh7rRWdoTHWZJtmLhrw52pVcFIb+IzgD1tfFcw= Cancel-Lock: sha1:3TLCXPFqBT+Yo5LMTaMithX0vfc= X-NNTP-Posting-Host: eJwFwYEBwCAIA7CXLIPWnSMg/59gEh/BkjPoMTF2a3tSrmVyWKvPWWEFoRPpTASW9s9dw/sACS4QaQ== Xref: csiph.com comp.lang.javascript:27694 Stefan Ram wrote: > "Leonardo Azpurua" writes: >>My question (which is browser dependent, but there's no better place to >>ask browser related questions than here) is: do most "modern" browsers >>(say FireFox, Chrome, IE9+, Opera, Safari) automatically handle all the >>cleanup of a disposed element (detaching event handlers, freeing graphical >>resources, deallocating memory, etc) for all the elemets inside a disposed >>control, or is it necessary to provide a function to handle all of it >>explicitly? > > The garbage collectors should take care of JavaScript objects and of > DOM objects. But some collectors cannot clean up in all situations. > To be on the safe side: > > - avoid circular references between JavaScript objects and DOM objects > - avoid using closure variables in event handlers > - avoid using inline event handlers (onclick='f()') > - avoid using expando properties > - nullify expando properties and DOM references when not needed anymore The IE memory leak issue has been resolved as of IE 9, so given the target environments none of this is necessary anymore. Therefore, the programming language to which these measures applied, was JScript, not JavaScript, and only the MSHTML DOM, not all DOMs. -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.