Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
Worker objects are not freed

I am noticing that in both Google Chrome and Microsoft Edge the Worker objects are not garbage collected. After running the following standalone simple test case, doing memory profile and checking for Worker class shows all the worker objects as retained.

<html>
        <body>
                <div id="app"></div>
                <script>
                        const js = 'var array = new Array(1024*1024).fill("Hello world")';
                        const blob = new Blob([js], { type: 'application/javascript' });
                        const wurl = URL.createObjectURL(blob);
                        for(let i=1;i<=100;i++) {
                                const w = new Worker(wurl);
                                const result = { id: i };
                                document.getElementById('app').innerHTML = JSON.stringify(result);
                                w.terminate();
                        }
                </script>
        </body> 
</html>

How to ensure the worker objects are freed?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Off the top of my head I'd say that your problem lies with the const w = new Worker... part. I'm guessing the garbage cleanup isn't taking because the value of w cannot be reassigned, and in any case block cleanup is irrelevant because it's a detached process to begin with. Try changing it to var w = new Worker..., leaving the rest unchanged.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!