From d2e603d28dfbb73029ef5621e188a35c79169525 Mon Sep 17 00:00:00 2001 From: Y-Kamata Date: Wed, 2 Nov 2011 15:12:31 +0900 Subject: [PATCH 1/9] ui.widget: modified _createWidget method and added __destroy method. Fixed #7808 - ui.widget Memory (private bytes of IE process) increases when create and destroy of the simple widget are repeated. --- ui/jquery.ui.widget.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 578d330ba33..248bc325653 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -195,6 +195,11 @@ $.Widget.prototype = { if ( element !== this ) { $.data( element, this.widgetName, this ); this._bind({ remove: "destroy" }); + // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 + this.element.bind( "remove." + this.widgetName, + {widgetName: this.widgetName}, + this.__destroy); + this.document = $( element.ownerDocument ); this.window = $( this.document[0].defaultView || this.document[0].parentWindow ); } @@ -203,6 +208,11 @@ $.Widget.prototype = { this._trigger( "create" ); this._init(); }, + // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 + $.Widget.prototype.__destroy = function(e){ + var self = $(this).data(e.data.widgetName); + self.destroy(); + }, _getCreateOptions: $.noop, _create: $.noop, _init: $.noop, From d02ac442f46af2a7f14671bbefad1d100b9b5bd6 Mon Sep 17 00:00:00 2001 From: Y-Kamata Date: Wed, 2 Nov 2011 15:24:23 +0900 Subject: [PATCH 2/9] bug fix --- ui/jquery.ui.widget.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 248bc325653..aac150fd7a2 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -197,8 +197,8 @@ $.Widget.prototype = { this._bind({ remove: "destroy" }); // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 this.element.bind( "remove." + this.widgetName, - {widgetName: this.widgetName}, - this.__destroy); + {widgetName: this.widgetName}, + this.__destroy); this.document = $( element.ownerDocument ); this.window = $( this.document[0].defaultView || this.document[0].parentWindow ); @@ -209,7 +209,7 @@ $.Widget.prototype = { this._init(); }, // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 - $.Widget.prototype.__destroy = function(e){ + __destroy = function(e){ var self = $(this).data(e.data.widgetName); self.destroy(); }, From a2df8e87ee909c65c05149a0829073c175320d29 Mon Sep 17 00:00:00 2001 From: Y-Kamata Date: Wed, 2 Nov 2011 15:27:08 +0900 Subject: [PATCH 3/9] bugfix __destroy --- ui/jquery.ui.widget.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index aac150fd7a2..62e63cdd618 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -209,10 +209,10 @@ $.Widget.prototype = { this._init(); }, // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 - __destroy = function(e){ - var self = $(this).data(e.data.widgetName); - self.destroy(); - }, + __destroy: function(e){ + var self = $(this).data(e.data.widgetName); + self.destroy(); + }, _getCreateOptions: $.noop, _create: $.noop, _init: $.noop, From 40ae50b4b0a855efe9f18a213246b787137b7c19 Mon Sep 17 00:00:00 2001 From: Y-Kamata Date: Wed, 2 Nov 2011 15:33:25 +0900 Subject: [PATCH 4/9] modified _createWidget --- ui/jquery.ui.widget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 62e63cdd618..dbab959c555 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -194,8 +194,8 @@ $.Widget.prototype = { if ( element !== this ) { $.data( element, this.widgetName, this ); - this._bind({ remove: "destroy" }); // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 + //this._bind({ remove: "destroy" }); this.element.bind( "remove." + this.widgetName, {widgetName: this.widgetName}, this.__destroy); From c6fc85038b1996e7bda34225df291599d0a8e1d7 Mon Sep 17 00:00:00 2001 From: Y-Kamata Date: Wed, 2 Nov 2011 23:32:36 +0900 Subject: [PATCH 5/9] Widget:modify _bind method. The reference of element and instance is deleted. --- ui/jquery.ui.widget.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index dbab959c555..764e4c8ddca 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -194,12 +194,7 @@ $.Widget.prototype = { if ( element !== this ) { $.data( element, this.widgetName, this ); - // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 - //this._bind({ remove: "destroy" }); - this.element.bind( "remove." + this.widgetName, - {widgetName: this.widgetName}, - this.__destroy); - + this._bind({ remove: "destroy" }); this.document = $( element.ownerDocument ); this.window = $( this.document[0].defaultView || this.document[0].parentWindow ); } @@ -208,11 +203,6 @@ $.Widget.prototype = { this._trigger( "create" ); this._init(); }, - // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 - __destroy: function(e){ - var self = $(this).data(e.data.widgetName); - self.destroy(); - }, _getCreateOptions: $.noop, _create: $.noop, _init: $.noop, @@ -332,8 +322,13 @@ $.Widget.prototype = { $( this ).hasClass( "ui-state-disabled" ) ) { return; } - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); + //return ( typeof handler === "string" ? instance[ handler ] : handler ) + // .apply( instance, arguments ); + // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 + var ret = ( typeof handler === "string" ? instance[ handler ] : handler ) + .apply( instance, arguments ); + instance = null; + return ret; } var match = event.match( /^(\w+)\s*(.*)$/ ), eventName = match[1] + "." + instance.widgetName, @@ -343,6 +338,8 @@ $.Widget.prototype = { } else { element.bind( eventName, handlerProxy ); } + // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 + element = null; }); }, From e2989fa9632940543c2a1a4faf26837e0d45dc63 Mon Sep 17 00:00:00 2001 From: Y-Kamata Date: Thu, 3 Nov 2011 08:27:24 +0900 Subject: [PATCH 6/9] Widget: modify _bind method --- ui/jquery.ui.widget.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 764e4c8ddca..e3c399ce3d7 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -322,13 +322,13 @@ $.Widget.prototype = { $( this ).hasClass( "ui-state-disabled" ) ) { return; } - //return ( typeof handler === "string" ? instance[ handler ] : handler ) - // .apply( instance, arguments ); + return ( typeof handler === "string" ? instance[ handler ] : handler ) + .apply( instance, arguments ); // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 - var ret = ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); - instance = null; - return ret; + //var ret = ( typeof handler === "string" ? instance[ handler ] : handler ) + // .apply( instance, arguments ); + //instance = null; + //return ret; } var match = event.match( /^(\w+)\s*(.*)$/ ), eventName = match[1] + "." + instance.widgetName, @@ -339,6 +339,7 @@ $.Widget.prototype = { element.bind( eventName, handlerProxy ); } // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 + instance = null; element = null; }); }, From bc7d587f31e6ed49f972391fda31dd6ee9eeaef6 Mon Sep 17 00:00:00 2001 From: Y-Kamata Date: Thu, 3 Nov 2011 08:31:04 +0900 Subject: [PATCH 7/9] revert --- ui/jquery.ui.widget.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index e3c399ce3d7..5cb70a7df42 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -322,13 +322,13 @@ $.Widget.prototype = { $( this ).hasClass( "ui-state-disabled" ) ) { return; } - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); - // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 + // return ( typeof handler === "string" ? instance[ handler ] : handler ) + // .apply( instance, arguments ); + bugfix memory leak http://bugs.jqueryui.com/ticket/7808 //var ret = ( typeof handler === "string" ? instance[ handler ] : handler ) - // .apply( instance, arguments ); - //instance = null; - //return ret; + .apply( instance, arguments ); + instance = null; + return ret; } var match = event.match( /^(\w+)\s*(.*)$/ ), eventName = match[1] + "." + instance.widgetName, @@ -339,7 +339,6 @@ $.Widget.prototype = { element.bind( eventName, handlerProxy ); } // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 - instance = null; element = null; }); }, From e362ccf56d997275ecbdd89bc4d7658606840ecc Mon Sep 17 00:00:00 2001 From: Y-Kamata Date: Thu, 3 Nov 2011 08:32:56 +0900 Subject: [PATCH 8/9] revert2 --- ui/jquery.ui.widget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 5cb70a7df42..b78fbe7d85b 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -324,7 +324,7 @@ $.Widget.prototype = { } // return ( typeof handler === "string" ? instance[ handler ] : handler ) // .apply( instance, arguments ); - bugfix memory leak http://bugs.jqueryui.com/ticket/7808 + // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 //var ret = ( typeof handler === "string" ? instance[ handler ] : handler ) .apply( instance, arguments ); instance = null; From ce89219b370ccbfc03a3c3efa39e3b41e9cd3823 Mon Sep 17 00:00:00 2001 From: Y-Kamata Date: Thu, 3 Nov 2011 08:34:01 +0900 Subject: [PATCH 9/9] revert3 --- ui/jquery.ui.widget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index b78fbe7d85b..b486aa9fdad 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -325,7 +325,7 @@ $.Widget.prototype = { // return ( typeof handler === "string" ? instance[ handler ] : handler ) // .apply( instance, arguments ); // bugfix memory leak http://bugs.jqueryui.com/ticket/7808 - //var ret = ( typeof handler === "string" ? instance[ handler ] : handler ) + var ret = ( typeof handler === "string" ? instance[ handler ] : handler ) .apply( instance, arguments ); instance = null; return ret;