Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

memory leak ui.widget #513

Closed
wants to merge 9 commits into from

3 participants

Y-Kamata Scott González Jörn Zaefferer
Y-Kamata

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.

master code memory leak test
http://jsfiddle.net/NzJGH/5/

my code memory leak test (fixed)
http://jsfiddle.net/yoshi6jp/NzJGH/11/

added some commits November 02, 2011
Y-Kamata 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.
d2e603d
Y-Kamata bug fix d02ac44
Y-Kamata bugfix __destroy a2df8e8
Y-Kamata modified _createWidget 40ae50b
Scott González

Can you explain what's causing the memory leak? I really don't want to land this fix without knowing, because if the solution is to not use ._bind() then I feel like that leaves open a huge possibility for future leaks.

ui/jquery.ui.widget.js
@@ -322,8 +322,13 @@ $.Widget.prototype = {
322 322
 						$( this ).hasClass( "ui-state-disabled" ) ) {
323 323
 					return;
324 324
 				}
325  
-				return ( typeof handler === "string" ? instance[ handler ] : handler )
326  
-					.apply( instance, arguments );
  325
+				//return ( typeof handler === "string" ? instance[ handler ] : handler )
  326
+				//	.apply( instance, arguments );
  327
+        // bugfix memory leak http://bugs.jqueryui.com/ticket/7808
  328
+				var ret = ( typeof handler === "string" ? instance[ handler ] : handler )
  329
+                    .apply( instance, arguments );
  330
+        instance = null;
2
Scott González Owner

Doesn't this break the event handler for future events?

There is no problem because it makes it to null after the event in the future is executed.
function handlerProxy() {
:
instance = null;
retrun ret;
}

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

I'm not actually seeing any difference using sIEve (and it's not reporting any leaks before or after your change).

Y-Kamata

Performance monitor result. (Windows XP SP3 + IE8)

iexprloer#1 (fix code)
http://jsfiddle.net/yoshi6jp/NzJGH/12/
"55463936" --> "54935552" (not increase)

iexplorer#2 (master code)
http://jsfiddle.net/NzJGH/5/
"54763520" --> "64102400" (increase)

"(PDH-CSV 4.0) ()(-540)","\KAMATAPC2\Process(iexplore#1)\Private Bytes","\KAMATAPC2\Process(iexplore#2)\Private Bytes"
"11/03/2011 08:38:19.406","23760896","23486464"
"11/03/2011 08:38:34.406","23760896","23486464"
"11/03/2011 08:38:49.406","55463936","23560192"
"11/03/2011 08:39:04.406","55463936","54763520"
"11/03/2011 08:39:19.406","55463936","54960128"
"11/03/2011 08:39:34.406","55263232","54960128"
"11/03/2011 08:39:49.406","55263232","54960128"
"11/03/2011 08:40:04.406","55263232","55091200"
"11/03/2011 08:40:19.406","55263232","55611392"
"11/03/2011 08:40:34.406","55263232","55762944"
"11/03/2011 08:40:49.406","55263232","56188928"
"11/03/2011 08:41:04.406","55263232","56631296"
"11/03/2011 08:41:19.406","55263232","57049088"
"11/03/2011 08:41:34.406","55197696","58359808"
"11/03/2011 08:41:49.406","55197696","58294272"
"11/03/2011 08:42:04.406","55197696","58433536"
"11/03/2011 08:42:19.406","55197696","58748928"
"11/03/2011 08:42:34.421","55197696","59228160"
"11/03/2011 08:42:49.421","55197696","59400192"
"11/03/2011 08:43:04.421","55197696","60264448"
"11/03/2011 08:43:19.421","55132160","60547072"
"11/03/2011 08:43:34.421","55132160","60751872"
"11/03/2011 08:43:49.421","55066624","61255680"
"11/03/2011 08:44:04.421","55066624","61505536"
"11/03/2011 08:44:19.421","55066624","62062592"
"11/03/2011 08:44:34.421","55066624","62377984"
"11/03/2011 08:44:49.421","55066624","62869504"
"11/03/2011 08:45:04.421","55066624","63242240"
"11/03/2011 08:45:19.421","54935552","63799296"
"11/03/2011 08:45:34.421","54935552","64102400"

Jörn Zaefferer
Owner

We've never been able to recreate the issue and we'll drop support for IE6 in 1.10.

Jörn Zaefferer jzaefferer closed this October 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 9 additions and 2 deletions. Show diff stats Hide diff stats

  1. 11  ui/jquery.ui.widget.js
11  ui/jquery.ui.widget.js
@@ -322,8 +322,13 @@ $.Widget.prototype = {
322 322
 						$( this ).hasClass( "ui-state-disabled" ) ) {
323 323
 					return;
324 324
 				}
325  
-				return ( typeof handler === "string" ? instance[ handler ] : handler )
326  
-					.apply( instance, arguments );
  325
+	//			return ( typeof handler === "string" ? instance[ handler ] : handler )
  326
+	//				.apply( instance, arguments );
  327
+        // bugfix memory leak http://bugs.jqueryui.com/ticket/7808
  328
+				var ret = ( typeof handler === "string" ? instance[ handler ] : handler )
  329
+                    .apply( instance, arguments );
  330
+        instance = null;
  331
+        return ret;
327 332
 			}
328 333
 			var match = event.match( /^(\w+)\s*(.*)$/ ),
329 334
 				eventName = match[1] + "." + instance.widgetName,
@@ -333,6 +338,8 @@ $.Widget.prototype = {
333 338
 			} else {
334 339
 				element.bind( eventName, handlerProxy );
335 340
 			}
  341
+			// bugfix memory leak http://bugs.jqueryui.com/ticket/7808
  342
+			element = null;
336 343
 		});
337 344
 	},
338 345
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.