Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

225
Vistas
Javascript Gif generation piling up blobs in browser memory

I'm using this library to generate gifs (https://github.com/jnordberg/gif.js). When it generates a gif file into blob, it does so in the browser memory and does not clean it afterwards, piling up files so that in continued use without a refresh, the page simply crashes.

You may replicate it by accessing its own demo here: (http://jnordberg.github.io/gif.js/). When you open up the network or sources tab, you'll see a few blobs loaded there, once you go to the page and regenerate any example image by changing its properties (like quality etc), it will generate new blobs without clearing the old ones.

For me it's a big problem because I'm generating hundreds of heavy animated gifs and the page crashes, so I need to find a way to remove these blobs from memory. Ideally I want to be able to do this without changing the gif.js library, maybe if I can access these blobs by reference somehow?

Any ideas?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The example is forgetting to release the blob URL that was created once you no longer need it.

Note that the lib doesn't create the blob URL, so the caller of the lib is responsible for creating and releasing the blob by calling URL.createObjectURL() and URL.revokeObjectUrl()

let lastBlobUrl;

var gif = new GIF({
  workers: 2,
  quality: 10
});

// add a image element
gif.addFrame(imageElement);

// or a canvas element
gif.addFrame(canvasElement, {delay: 200});

// or copy the pixels from a canvas context
gif.addFrame(ctx, {copy: true});


gif.on('finished', function(blob) {
  // You have to call this when you no longer need that URL.
  if (lastBlobUrl) {
     URL.revokeObjectURL(lastBlobUrl)
  }
  lastBlobUrl = window.open(URL.createObjectURL(blob));
});

gif.render();
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda