According to Memory Leaks in Microsoft Internet Explorer there is a leak when using XHMLHttpRequest that is not cleared by the usual approaches. See the section titled "Memory Leaks and Ajax/XHR" towards the bottom of the post. I've confirmed that the application I'm working on suffers from this leak. The GWT generated/provided code uses delete xmlHttp.onreadystatechange in XMLHTTPRequest.send to try to prevent the leak but that doesn't work. However, the post another way to prevent memory leak in IE when using XMLHTTPRequest suggests using xmlHttp.onreadystatechange = Constants.NULL; where NULL is defined as function() {}. GWT provides a nullMethod, defined as function nullMethod() { return window; } and setting xmlHttp.onreadystatechange = nullMethod; prevents the leak. I did the hacking to find this solution by modifying the generated javascript, to make this production worthy is going to be a bit tricky because XMLHTTPRequest is final with all its methods being static. Overriding isn't going to work so it's either produce a build of GWT that includes the fix or postprocess the generated JavaScript. Neither sounds like much fun.
It turns out that you can't reference nullMethod in a JSNI method. I had to create my own nullMethod in XMLHttpRequest by defining static native String nullMethod() /*-{ return ""; }-*/; and use that in XMLHTTPRequest.send instead.
Posted by Alex at May 29, 2007 11:15 PM