title: Javascript - Pause - Free Memory
body: <p>Using the below it refreshes the screen using the dataRefreshButton function based else where in the code.</p>
  
  <p>However I am finding Firefox, Chrome and IE do not have the chance to free up memory. So I am trying to pause the refresh every so often, to try to give the browser the chance to catch. This does not seem to pause like I would expect, whether or not when it does, it will work fine in terms allowing memory to be freed.</p>
  
  <p>So question is, what is the best way to stop the refresh (setInterval) and then allow it to resume after approx ten seconds?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function getdata(){
  
          counter++;
          if(counter==20) {
  
             clearInterval(reset, 10000);
  
  
          }
          //window.alert(counter);
         document.getElementById('dataRefreshButton').click();
  
      }
  
  
      function reset() {
  
  
              intGetData = setInterval(getdata, 4000);
              counter=0;
  
  
      }
  
      var intGetData;
      var counter = 0;
  
      function sel1(){
          var ref = document.getElementById('AutoRefresh').checked;
  
  
          if(ref == true) {
  
  
              intGetData = setInterval(getdata, 4000);
  
  
    window.alert("Auto refresh on");
          }
  
          else{
              clearInterval(intGetData);  
           //   window.alert("Auto refresh off");   
  
          }
      }
  &lt;/script&gt;
  </code></pre>