livestampjs icon indicating copy to clipboard operation
livestampjs copied to clipboard

destroy doesn't remove the element causing memory leak

Open lostincomputer opened this issue 10 years ago • 2 comments

Memory is not freed when I call the destroy function

Root cause is this line: $livestamps = $livestamps.not($el);

basically, with .not(), the element isn't removed from the array. $livestamps still holds a reference to the element.

Code to reproduce the problem: $('#birth').livestamp(new Date('June 18, 1987')); $('#birth').livestamp('destroy'); $('#birth').livestamp(new Date('June 18, 1987')); $('#birth').livestamp('destroy'); $('#birth').livestamp(new Date('June 18, 1987')); $('#birth').livestamp('destroy');

You will notice that value of $livestamps.selector becomes longer and longer .not().not().not([object Object]) .not().not().not([object Object]).not().not([object Object]) .not().not().not([object Object]).not().not([object Object]).not().not([object Object])

lostincomputer avatar Jan 22 '15 23:01 lostincomputer

@mattbradley thoughts on this?

philfreo avatar Apr 15 '15 02:04 philfreo

Very nice find. This seems to be another quirk with using jQuery's methods to manage the list of livestamps (similar to #16). Maybe just adding and removing the livestamps from an array would be better. I'll look into this for v2.0.

mattbradley avatar Apr 24 '15 13:04 mattbradley