I've notice that Firefox causes my machine to thrash when I leave a page that has Seam Remoting JavaScript running for a long period of time (say, 12 hours). I read ( http://www.jackslocum.com/blog/2006/10/02/3-easy-steps-to-avoid-javascript-memory-leaks ) that it is a good idea to set XMLHttpRequest onreadystatechange handlers to null when you are done with them, but it looks like remote.js doesn't do this.
The sendAjaxRequest function sets onreadystate change here:
Seam.Remoting.sendAjaxRequest = function(envelope, path, callback, silent) { Seam.Remoting.log("Request packet:\n" + envelope); if (!silent) Seam.Remoting.displayLoadingMessage(); var asyncReq; if (window.XMLHttpRequest) { asyncReq = new XMLHttpRequest(); if (asyncReq.overrideMimeType) asyncReq.overrideMimeType('text/xml'); } else asyncReq = new ActiveXObject("Microsoft.XMLHTTP"); asyncReq.onreadystatechange = function() {Seam.Remoting.requestCallback(asyncReq, callback); } asyncReq.open("POST", Seam.Remoting.resourcePath + path, true); asyncReq.send(envelope); return asyncReq; }
Seam.Remoting.requestCallback = function(req, callback) { if (req.readyState == 4) { Seam.Remoting.hideLoadingMessage(); if (req.status == 200) { Seam.Remoting.log("Response packet:\n" + req.responseText); if (callback) callback(req.responseXML); } else alert("There was an error processing your request. Error code: " + req.status); } }
I don't know if it will help the memory problem (I always thought the request object was garbage collected anyway) but I've made the change in CVS anyway. Thanks for pointing this out.