/    Sign up×
Community /Pin to ProfileBookmark

Preventing memory leaks

[code=html]function addEvent(){
x = document.getElementById(“x”);
if(x.addEventListener){
x.addEventListener(‘click’,function(){/*do something*/},true);
}
//etc
}[/code]

Does the (principle behind) above script leak memory via a circular reference involving the dom and js core? and if so what is a practice work around?

I know something like this won’t cause a problem (if it does leak) but im working with some code that is quite complicated and is at the upper end of my knowledge.

THanks

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@DokAug 29.2008 — Memory leaks related to circular ref. in IE6 have been corrected by MS and are no longer an issue.

Don't double post: http://www.webdeveloper.com/forum/showthread.php?t=190042.
Copy linkTweet thisAlerts:
@TaboauthorAug 29.2008 — Memory leaks related to circular ref. in IE6 have been corrected by MS and are no longer an issue.

Don't double post: http://www.webdeveloper.com/forum/showthread.php?t=190042.[/QUOTE]

IE 6 is still in use.

It is not a double post, one is asking for a list of resources relating to a particular topic, and the other is asking help with a piece of code within that category. Sorry.
Copy linkTweet thisAlerts:
@DokAug 29.2008 — IE 6 is still in use.[/QUOTE]
I didn't say otherwise ? I'm taking about the memory leaks in IE6 which have been corrected by MS.

Otherwise see these articles from ajaxian.com - they can probaly get you started.
×

Success!

Help @Tabo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...