title: How do I fix or work around this memory leak in fetch?
body: <p>Similar to this question:
  <a href="https://stackoverflow.com/questions/52696539/fetch-api-leaks-memory-in-chrome">Fetch API leaks memory in Chrome</a></p>
  <p>When using fetch to regularly poll data, Chrome's memory usage continually increases without ever releasing the memory, which eventually causes a crash.</p>
  <p><a href="https://jsfiddle.net/abfinz/ahc65y3s/13/" rel="nofollow noreferrer">https://jsfiddle.net/abfinz/ahc65y3s/13/</a></p>
  <pre><code>const state = {
      response: {},
    count: 0
  }
  
  function poll(){
      fetch('https://upload.wikimedia.org/wikipedia/commons/3/3d/LARGE_elevation.jpg')
      .then(response =&gt; {
        state.response = response;
        state.count = state.count + 1;
        if (state.count &lt; 20){
          console.log(state.count);
                  setTimeout(poll, 3000);
        } else {
          console.log(&quot;Will restart in 1 minute&quot;);
          state.count = 0;
          setTimeout(poll, 60000);
        }
      });
  }
  
  poll();
  </code></pre>
  <p>This JSFiddle demonstrates the issue fairly well. By polling for data every 3 seconds, it seems that something is causing Chrome to continually hold onto the memory. If I let it stop and wait for a few minutes, it usually will release the memory, but if polling continues, it usually holds onto it. Also, if I let it run for a few full cycles, even forcing garbage collection from the perfomance tab of the dev tools doesn't always release all of the memory.</p>
  <ul>
  <li>The memory doesn't show up in the JS Heap. I have to use the Task Manager to see it.</li>
  <li>Occasionally, the memory will clear while actively polling, but inevitably builds to extreme levels.</li>
  <li>Edge also shows the issue, but seems to be more proactive in clearing the memory. Though it still eventually builds to 1GB+ of extra memory usage.</li>
  </ul>
  <p>Am I doing something wrong, or is this a bug? Any ideas on how I can get this kind of polling to work long-term without the memory leak?</p>