title: Possible memory leaks using Web Workers (Garbage Collector)
body: <p>I have an app which calls web worker after the button click. The calculations are moved to worker to relieve UI and make it responsive to user actions while calculations are being made.</p>
  <p>Everything goes okay and after about 0.8-1.5s the worker sends a response. In <code>worker.onmessage</code> I perform all the needed DOM actions, but after this Garbage Collector appears and practically blocks the UI for 2 or more seconds depending on CPU. This is really confusing me, because UI blocking is what I want to prevent.</p>
  <p>Here's the screenshot of timeline/memory console tab:
  <img src="https://i.imgur.com/zUoHa.jpg" alt="" /></p>
  <p>As you can see Garbage Collector events happen just after all DOM manipulations. Actually there's only one repaint event (<code>DocumentFragment</code> is used).</p>
  <p>Main js code:</p>
  <pre><code>var sortWorker = new Worker('js/contactsorter.js');
  sortWorker.onmessage = function(e) {
      var messages = [];
      e.data.forEach(function(userDoc) {
          var contactSection = _drawContact(userDoc);
          messages.push(contactSection);
      });
      
      meta.append(messages); // this actually appends document fragment as a child
  };
  
  sortWorker.postMessage(postMessageData);
  </code></pre>
  <p>contactsorter.js (worker):</p>
  <pre><code>onmessage = function(e) {
      var uid, output = [], usersStat = {};
  
      // calculations...
      
      postMessage(output);
      close();
  };
  </code></pre>
  <p>Is there any way to avoid these Garbage Collector events in this place or not?</p>
  <p>UPD: it seems to me that Garbage Collector event(s) time depends on data amount that was sent to worker.<br />
  UPD2: After shutdown and boot Garbage Collector events happen only twice thus blocking UI for less than a second. Hm?</p>