Note that there are some explanatory texts on larger screens.

plurals
  1. POPossible memory leaks using Web Workers (Garbage Collector)
    primarykey
    data
    text
    <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 worker.onmessage i perform all the needed DOM actions. But after this GC 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: <a href="https://i.imgur.com/zUoHa.jpg" rel="noreferrer">http://i.imgur.com/zUoHa.jpg</a></p> <p>As you can see GC events happen just after all DOM manipulations. Actually there's only one repaint event (DocumentFragment 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 GC events in this place or not?</p> <p>UPD: it seems to me that GC event(s) time depends on data amount that was sent to worker. UPD2: After shutdown and boot GC events happen only twice thus blocking UI for less than a second. Hm?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload