Leaking memory with setInterval when elements are removed #79

Closed
jookyboi opened this Issue May 25, 2012 · 1 comment

Comments

Projects
None yet
2 participants

Running into an issue where the following lines is preventing the "self" object from being deleted from memory upon removal of the element.

if ($s.refreshMillis > 0) {
    setInterval(function() { self.each(refresh); }, $s.refreshMillis);
}

I have a Firefox addon which does a periodic poll for new info. The info has a timestamp and so I am using $("abbr").timeago() to get the pretty dates to output. However, when new information comes in, I do have to call $("tr.info").remove(), which removes the row and the embedded "abbr" elements from the DOM. However, as the element still lives within timeago's setInterval, it ends up becoming a zombie object.

Owner

rmm5t commented May 27, 2012

Thanks for the report. I have plans to start a Timeago rewrite that incorporates a lot of feedback like this that it has received in the past couple years.

Timeago is more frequently being used in environments where the timestamp dom elements come and go. I'd like to change timeago such that it better responds to such environments without having to call $.fn.timeago() on newly added dom elements all the time or worry about removed dom elements.

jookyboi closed this Feb 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment