title: Huge Memory Leaks with XMLHttp POST Request
body: <p>How can i avoid XHR POST Memory leak? I go through lots of web pages regarding XHR memory leak but there is no good solutions. My problem is almost similar to <a href="http://nullprogram.com/blog/2013/02/08/" rel="noreferrer">this</a>  That blog explains the problem but no solutions.</p>
  
  <p>My Problem: 
  I have a web app which Continuously send date to server (2Mb to 80Mb) and it will make 10 to 300 requests. It is POST request. for GET request no big problem like this.</p>
  
  <p>How can i solve this?
  Circular reference, Scope , closer etc i try but no success.
  i try to use delete keyword for readystate change, delete previous xhr object , try to reuse xhr , xhr reference to null , changing coding patters etc     </p>
  
  <p>This is  the sample code. this is the functionality i need</p>
  
  <pre><code> var base_string =  "ABCDEFGHIJKLMNOPQUST01234567890!@#$%^&amp;:ABCDEFGHIJKLMNOPQUST01234567890!@#$%^&amp;ABCDEFGHIJKLMNOPQUST01234567890!@#$%^&amp;";
              base_string += base_string;  
              base_string += base_string; 
              base_string += base_string; 
              base_string += base_string;  
              base_string += base_string;  
              base_string += base_string;  
              base_string += base_string;  
              base_string += base_string; 
              base_string += base_string;  
              base_string += base_string;  
              base_string += base_string; 
              base_string += base_string;  
              base_string += base_string;  
              base_string += base_string;  
              base_string += base_string;  
              base_string += base_string;  
              base_string += base_string;  
              this.sampleData = base_string;
              var dataToSend = this.sampleData.substring( 0, 2000000 );
  
  
  
             this.xhr = [];
             this.xhr[0] = new XMLHttpRequest();
             function sendRequest (){
                 var Self = this;
                 Self.xhr[0].onload = function (test) {
                     sendRequest ();
                 };
  
                 Self.xhr[0].open("POST", "http://localhost/upload.php" + "?n=" +  Math.random(), true);
                 Self.xhr[0].send(dataToSend);
             }
             sendRequest ();
  </code></pre>
  
  <p>How can i accomplish this without Memory leaks?</p>