Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

297
Visualizações
Memory Leak: JavaScript - passing array buffer to Web Worker using transferable object, GC doesn't kick in

So, I am passing video buffer(Float32Array buffer) to worker thread as a transferable object, it happens for each frame of the video(meaning, continuously video frames are being passed to worker). I did memory profiling, and worker thread is retaining the object, it seems garbage collector doesn't kick in. How to handle this case? I don't think one can invoke GC explicitly in JavaScript.

Here is the code snippet how I am passing video buffer to worker thread:

this.worker.postMessage({
          command: 'SetVideoBuffer',
          data: {
            videoFrame: videoFrame
          }
        },
          [videoFrame.buffer]);

Also, I tried setting the buffer at worker side to 'null', it didn't help.

Any idea how to resolve this, is this chrome thing? Please help.

Thank you!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

So, I got the workaround of this problem, looks like if one sends back the video buffer back to main thread where it was created, GC does kick in and clear the heap.

By using the same, zero-copy(transferable objects) way, I transferred the buffer back to the main thread, memory leak issue got resolved.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda