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

198
Views
Js ArrayBuffer memory leak

I have a problem with ArrayBuffer. I don't understand why memory not frees up. Maybe someone knows how to fix it.

Code in github

Video in youtube

  // Main thread
  const startLongTask = () => {
    setLoading(true);

    const worker = new Worker(
      new URL("../webworkers/matrix.js", import.meta.url)
    );

    worker.onmessage = ({ data }) => {
      setLoading(false);
      console.log(data);

      worker.terminate();
    };

    const matrix = new Uint8Array(1000000000);
    worker.postMessage(matrix, [matrix.buffer]);
  };
// Worker thread
onmessage = ({ data: matrix }) => {
  const matrixView = new DataView(matrix.buffer);
  for (let i = 0; i < matrix.byteLength; i++) {
    matrixView.setInt8(i, i >= 255 ? 255 : i);
  }
  postMessage(matrix, [matrix.buffer]);
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It looks like there is memory leak because of console.log(data);

With console.log

https://monosnap.com/file/Qwbu7LRGWFaHptic1bG5YLsVGyKj7d

Without console.log

https://monosnap.com/file/3yrkGDeCQo1jWxQ10SSDUDFXvd9g8T

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!