Skip to content

Image Widget memory leak when a lot of updates #3170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
joseph2rs opened this issue Mar 25, 2021 · 1 comment
Closed

Image Widget memory leak when a lot of updates #3170

joseph2rs opened this issue Mar 25, 2021 · 1 comment

Comments

@joseph2rs
Copy link

joseph2rs commented Mar 25, 2021

Description

Browser memory leak caused by Image Widget not revoking the ObjectURLs.

Reproduce

  • Create an Image Widget from an array (not from a url)
  • Perform a lot of updates of the image (for example in a loop)

Expected behavior

Context

  • ipywidgets version 7.6.3
  • Operating System and version: Ubuntu 20, Windows 10
  • Browser and version: Firefox 86, Chomium 89

Bug is here: https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/controls/src/widget_image.ts#L65

At each update, a URL.createObjectURL is performed. As a result, the browser is "storing" the blob in memory. But the memory is never cleaned, because URL.revokeObjectURL is never called

    // Clean up the old objectURL
    const oldurl = this.el.src;
    this.el.src = url;
    if (oldurl && typeof oldurl !== 'string') {
      URL.revokeObjectURL(oldurl);
    }

oldurl is always a string, so the revokeObjectURL is never called.

If using JupyterLab

  • JupyterLab version: 3.0.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants