Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript responseXML memory leak
    text
    copied!<p>I've been tracking down some memory leaks in a Javascript file I've been working with, and I've found one of the last reamining culprits. When I get the responseXML from an XMLHttpRequest, I don't think the response ever gets deleted. I don't know how to delete it, I tried removing the child nodes and then setting it to null (Hoping garbage collection would work) and I also tried using the delete key word. Neither of these things seemed to help. Below is some of the offending code (I omitted some timeout stuff that removes the request itself, but that is not what's causing the memory leak).</p> <pre><code>var request = new XMLHttpRequest(); request.open("GET", url, true); request.onreadystatechange = onReadyStateChange1; request.send(); } function onReadyStateChange1() { if (4 == request.readyState) { if (request.status == 200) { request.responseXML; //It leaks even if I just do this. //me.ParseData(request.responseXML); me.disconnected = 0; } else { me.disconnected += 1; } request.onreadystatechange = noop; //noop is an empty function request = null; me = null; } } </code></pre> <p>As you can see in the code, I don't even call ParseData, I just put <code>request.responseXML;</code> and it still leaks. If I comment that line out as well, though, the leak is gone. Meaning the leak is not in the ParseData function or elsewhere, it is the responseXML. I believe it has to do with the tree structure of responseXML, the DOM tree is probably not being cleaned properly. If anyone could help me that would be great.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload