Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory leak using jquery-ui/datepicker

I'm using these scripts (where jquery-ui[].custom.js is the datepicker plugin):

<script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.13.custom.js" type="text/javascript"></script>
<script id="formvalidation" type="text/javascript">
$(document).ready(function () {
    $(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' });
});
</script>

On this input element (inside a form):

<input type="text" name="Date" class="datepicker" />

The page loads fine and when I click in the input field the datepicker pops up correctly, but I get a memory leak (in every browser) once a date is selected and the datepicker disappears. This causes that bit of JS to crash or slow down the browser because of a memory leak in jquery-1.5.1.js:

Line: 1520 Error: Out of memory

When debugging I see the error line is at 2310

jQuery.event.remove( elem, type + types );

A little context:

// Unbind all events for the element
if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
    types = types || "";
    for ( type in events ) {
        jQuery.event.remove( elem, type + types );
    }
    return;
}

Am I doing something wrong or maybe its a bug in jquery? I'm also using the validation plugin but the same error occurs when I disable it.

[Solved?] Since I can't post my answer for 8 hours:

Solved the leak by switching to the minimal version of jquery (jquery-1.5.1.min.js & jquery-ui-1.8.13.custom.min.js). It appears there is some discrepancy between the min version and the dev version.

Side question: Where would be a good place to bring this up if its not already an issue?

like image 679
Jamie Curtis Avatar asked May 26 '11 18:05

Jamie Curtis


1 Answers

Solved the leak by switching to the minimal version of jquery (jquery-1.5.1.min.js & jquery-ui-1.8.13.custom.min.js). It appears there is some discrepancy between the min version and the dev version.

Side question: Where would be a good place to bring this up if its not already an issue?

like image 109
Jamie Curtis Avatar answered Sep 19 '22 21:09

Jamie Curtis