title: Memory leaks when using AJAX JSON call
body: <p>In my javascript application I have big memory leak when making <code>AJAX</code> call to retrieve <code>JSON</code> object. Code is really simple:</p>
  
  <pre><code>function getNewMessage()
  {
      new_message = []; // this is global variable
      var input_for_ball = [];
      var sum;
      var i;
  
      var http = new XMLHttpRequest();
      http.open("GET", url + "/random_ball.json", false);
      http.onreadystatechange = function()
      {
          if(http.readyState === 4 &amp;&amp; http.status === 200)
          {
              var responseTxt = http.responseText;
              input_for_ball = JSON.parse('[' + responseTxt + ']');
          }
      }
      http.send(null);
  
      new_message = input_for_ball;
  }
  </code></pre>
  
  <p>This is called every 1 milisecond and as you see, its synchronous call. This function costs me 1MB every 1 second.</p>
  
  <p>When I use instead of <code>AJAX</code> just assigning to variable like:</p>
  
  <pre><code> input_for_ball = JSON.parse('[0,0,0,0,0,0,0,0,0,0]');
  </code></pre>
  
  <p>then its everything perfect. So error must be in my implementation of <code>AJAX</code> call. This happened when I use <code>jQuery AJAX</code> call too.</p>
  
  <p><strong>UPDATE 12/03/2013</strong></p>
  
  <p>As <code>Tom van der Woerdt</code> mentioned below, this really was intended behavior. So as <code>Matt B.</code> suggested, I have rewrote some code to make asynchronous calls possible and it helped a lot. Now my application memory consuming is stable and small.</p>