roman465
roman465

Reputation: 179

URL.revokeObjectURL doesn't remove blobs from "Sources" panel and from chrome://blob-internals/

The problem is basically what the title says. The minimal example to demonstrate it is below.

This function accepts a File object as an argument from <input type='file' /> field. It creates a URL and revokes it 5 seconds later.

const compress = (file) => {
  const img = new Image();
  img.src = URL.createObjectURL(file);
  console.log('url created');
  setTimeout(() => {
    URL.revokeObjectURL(img.src);
    console.log("url revoked");
  }, 5000);
};

The blob appears in the Sources panel and I would expect it to disappear (to be garbage collected) after 5 seconds, but it doesn't.

What could be the reason it's not garbage collected?

enter image description here

It's also not removed from chrome://blob-internals/

enter image description here

As far as I understand it's a memory leak. How can I fix it?

Upvotes: 6

Views: 624

Answers (0)

Related Questions