[jQuery] datePicker plugin IE memory leak fixed

[jQuery] datePicker plugin IE memory leak fixed

Hi,
I have just released an updated version of my date picker plugin:
http://kelvinluck.com/assets/jquery/datePicker/
Thanks to Sean McKenna who reported a memory leak in IE. This turned out
to be a pretty major one but relatively easy to fix and so I'd recommend
anyone using the date picker to upgrade ASAP...
I would like some advise on the cause of the problem and if there is a
more robust solution. Basically, when the calendar opens IE uses a bunch
more memory (~35MB on my system). When you switch months I was clearing
the old calendar from the DOM by doing this:
$('div.popup-calendar', _openCal).remove();
(basically calling remove on the div that contained it). This wasn't
freeing the memory in IE and another ~35MB or so was being used. And
when you closed the calendar and the pop up div was removed only the
last ~35MB was being freed up. As you can imagine, a recipe for disaster!
My solution was to call:
$('div.popup-calendar', _openCal).empty();
Before the remove command above. Now IE consistently uses ~35MB more
memory while the calendar is open and frees this when the calendar
closes. Much better.
I was wondering if it is expected behaviour to have to call empty before
remove when developing with jQuery or whether this should be done
internally?
One other problem I noticed is that if I chain the two calls (as I
should be able to):
$('div.popup-calendar', _openCal).empty().remove();
Now when the calendar opens it uses ~35MB more memory. When you switch
months for the first time it doubles this to ~70MB more memory. It stays
constant at this while you switch months and then frees the memory when
you close the calendar. It is interesting that the chained methods react
consistently differently to calling the methods one after the other - is
this expected or indicative of another bug?
Sorry for the long email but I'd appreciate it if anyone had any
feedback on these problems,
Cheers,
Kelvin :)
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/