Reviewers: Ray Ryan,
Message:
Review requested
Description:
HtmlUnit dies if the the same function object is used repeatedly as an
onreadystatechange callback. Using a function(){} literal leaks memory
on IE.
It looks like calling the Function constructor satisfies both
constraints, although it's far less efficient than this code should
otherwise be. The inefficiency is at least mitigated by the callback
being executed relatively infrequently and not in a blocking fashion
Please review this at http://gwt-code-reviews.appspot.com/104811
Affected files:
M user/src/com/google/gwt/xhr/client/XMLHttpRequest.java
Index: user/src/com/google/gwt/xhr/client/XMLHttpRequest.java
diff --git a/user/src/com/google/gwt/xhr/client/XMLHttpRequest.java
b/user/src/com/google/gwt/xhr/client/XMLHttpRequest.java
index
5674a2dd947e144a71b85e1071065016176bfc0a..08adeb60dae6455e288f8786baa8d9d0eb28cda2
100644
--- a/user/src/com/google/gwt/xhr/client/XMLHttpRequest.java
+++ b/user/src/com/google/gwt/xhr/client/XMLHttpRequest.java
@@ -113,7 +113,9 @@ public class XMLHttpRequest extends JavaScriptObject {
public final native void clearOnReadyStateChange() /*-{
var self = this;
$wnd.setTimeout(function() {
- self.onreadystatechange = function(){};
+ // Using a function literal here leaks memory on ie6
+ // Using the same function object kills HtmlUnit
+ self.onreadystatechange = new Function();
}, 0);
}-*/;
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors