René's URL Explorer Experiment


Title: [BUG]: Memory Leak - Heatmap redraws continuously grow Chromium renderer memory via unique PNG `data:` URLs · Issue #8097 · plotly/plotly.js · GitHub

Open Graph Title: [BUG]: Memory Leak - Heatmap redraws continuously grow Chromium renderer memory via unique PNG `data:` URLs · Issue #8097 · plotly/plotly.js

X Title: [BUG]: Memory Leak - Heatmap redraws continuously grow Chromium renderer memory via unique PNG `data:` URLs · Issue #8097 · plotly/plotly.js

Description: Description Every heatmap redraw sets the trace's SVG to a fresh canvas.toDataURL('image/png') (src/traces/heatmap/plot.js#L369). In Chromium, these distinct data-URL image resources remain retained in the document's image/resour...

Open Graph Description: Description Every heatmap redraw sets the trace's SVG to a fresh canvas.toDataURL('image/png') (src/traces/heatmap/plot.js#L369). In Chromium, these distinct data-URL image resources remain...

X Description: Description Every heatmap redraw sets the trace's SVG <image> to a fresh canvas.toDataURL('image/png') (src/traces/heatmap/plot.js#L369). In Chromium, these distinct data-URL imag...

Opengraph URL: https://github.com/plotly/plotly.js/issues/8097

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG]: Memory Leak - Heatmap redraws continuously grow Chromium renderer memory via unique PNG `data:` URLs","articleBody":"## Description\n\nEvery heatmap redraw sets the trace's SVG `\u003cimage>` to a fresh `canvas.toDataURL('image/png')` ([`src/traces/heatmap/plot.js#L369`](https://github.com/plotly/plotly.js/blob/v4.1.1/src/traces/heatmap/plot.js#L369)). In Chromium, these distinct data-URL image resources remain retained in the document's image/resource cache for the lifetime of the page. A heatmap that is updated repeatedly (e.g., live data, `Plotly.react` in a loop) therefore grows the renderer's native memory by approximately one image resource per update. The memory is not reclaimed while the page remains alive. The JS heap stays flat, so heap snapshots don't show the growth.\n\nWe hit this in a desktop app (Edge WebView2) that plots live measurements. A heatmap, refreshing about once a second, took the renderer from 1.2 GB to 13.5 GB in 3 h 13 min, after which it was killed with `RenderProcessExited, Reason=OutOfMemory`.\n\n## Screenshots/Video\n\nNo video, but here is the memory of the example below, measured over 10 minutes with plotly.js 4.1.1 (un-minified) in Chromium 153.0.8010.12 on Windows 11. A full GC was forced before each sample (`--js-flags=--expose-gc`, `gc()` twice); \"renderer\" is the renderer process's private memory.\n\n| Time | Updates | Renderer, as is | Renderer, with the workaround in Notes | JS heap (both) |\n| --- | ---: | ---: | ---: | ---: |\n| 0 min | 1 | 162 MB | 164 MB | 32 MB |\n| 1 min | ~160 | 391 MB | 388 MB | 32 MB |\n| 2 min | ~300 | 389 MB | 388 MB | 32 MB |\n| 4 min | ~550 | 660 MB | 549 MB | 32 MB |\n| 6 min | ~790 | 899 MB | 651 MB | 32 MB |\n| 8 min | ~1000 | 1090 MB | 705 MB | 32 MB |\n| 10 min | ~1300 | **1123 MB** | **483 MB** | 32 MB |\n\nAs is, the renderer gains about 0.7 MB per update, roughly 100 MB per minute at ~2.2 updates/s. With the workaround, memory remains bounded and can fall back substantially after reclamation. 4.0.0 behaves the same (139 -> 1310 MB over the same 10 minutes).\n\n## Steps to reproduce\n\n1. Save this as an HTML file and open it in Chrome or Edge:\n\n```html\n\u003c!doctype html>\n\u003cmeta charset=\"utf-8\">\n\u003cdiv id=\"plot\" style=\"width:900px;height:700px\">\u003c/div>\n\u003cscript src=\"https://cdn.plot.ly/plotly-4.1.1.js\">\u003c/script>\n\u003cscript>\n  // A \"live\" 1000x1000 heatmap: one more row is filled on every update.\n  const N = 1000;\n  let frame = 0;\n\n  function nextZ() {\n    frame++;\n    const z = [];\n    for (let r = 0; r \u003c N; r++) {\n      const row = new Array(N);\n      for (let c = 0; c \u003c N; c++) {\n        row[c] =\n          r \u003c= frame % N\n            ? Math.sin(r / 30 + c / 50 + frame / 10)\n            : NaN;\n      }\n      z.push(row);\n    }\n    return z;\n  }\n\n  async function update() {\n    await Plotly.react(\"plot\", [{ type: \"heatmap\", z: nextZ() }]);\n    setTimeout(update, 250);\n  }\n\n  update();\n\u003c/script>\n```\n\n2. Open the browser's Task Manager (Shift+Esc) and watch the tab's memory footprint (keep the tab/window in foreground).\n3. It climbs by roughly 100 MB a minute and does not come back down, while the JS heap (DevTools > Memory) stays at ~30 MB.\n\n### Notes\n\n**It's the data URLs, not Plotly's data handling.** I repeated the test without Plotly, using one SVG `\u003cimage>` whose `href` is set to a new 1580×1580 PNG on every update:\n- **A data URL each time:** renderer 186 → 1220 MB over 600 updates.\n- **The same PNG as a blob URL, revoking the previous one:** flat at ~500 MB.\n- **Replacing the `\u003cimage>` element instead of updating it:** still grows.\n- **Swapping the data URL for a blob URL one animation frame later:** still grows, because the data URL is loaded as soon as it is set.\n\n**Real-world numbers.** Edge WebView2 154.0.4258.37 with a 1580×1580 heatmap (2.5M points) updated about once a second. The renderer grew ~3.8 GB/h and crashed after 3 h 13 min at 13.5 GB, while the page's JS heap stayed between 0.45 and 1 GB.\n\n### Suggested fix\nIn `heatmap/plot.js`, use a blob URL for on-screen rendering and revoke the previous one. Keep the data URL for `toImage`, which serializes the SVG, where a `blob:` URL would not survive:\n\n```js\n// Instead of: 'xlink:href': canvas.toDataURL('image/png')\nif (gd._context._exportedPlot) {\n    image3.attr('xlink:href', canvas.toDataURL('image/png'));\n} else {\n    canvas.toBlob(function(blob) {\n        var node = image3.node();\n        if (!node || !blob) return;\n        var url = URL.createObjectURL(blob);\n        if (node._blobUrl) URL.revokeObjectURL(node._blobUrl);\n        node._blobUrl = url;\n        node.setAttributeNS(xmlnsNamespaces.xlink, 'xlink:href', url);\n    });\n}\n```\n\nThe last blob URL should also be revoked when the image is removed or the plot is purged. `toBlob` is asynchronous, so the previous image stays on screen until the new one is ready, which looks the same as today. A synchronous alternative is to decode the data URL into a `Blob` and use `URL.createObjectURL`, which is what our workaround does.\n\nI haven't built or tested this patch inside plotly.js, but it works for us in our app.\n\n`traces/image/plot.js` builds its `href` the same way and probably has the same problem; I haven't measured it.\n\n### Workaround\nSwap each new data URL for a blob URL from a `MutationObserver` on the plot. It must happen in the same task as Plotly's update; in my testing, waiting until the next animation frame is already too late:\n\n```js\nconst blobs = new WeakMap();\nnew MutationObserver((records) => {\n  for (const { target, attributeName, attributeNamespace } of records) {\n    if (attributeName !== \"href\" || target.localName !== \"image\") continue;\n    const href = target.getAttributeNS(attributeNamespace, \"href\");\n    if (!href?.startsWith(\"data:image/png;base64,\")) continue;\n    const bin = atob(href.slice(22));\n    const bytes = new Uint8Array(bin.length);\n    for (let i = 0; i \u003c bin.length; i++) bytes[i] = bin.charCodeAt(i);\n    const url = URL.createObjectURL(new Blob([bytes], { type: \"image/png\" }));\n    target.setAttributeNS(attributeNamespace, attributeNamespace ? \"xlink:href\" : \"href\", url);\n    if (blobs.has(target)) URL.revokeObjectURL(blobs.get(target));\n    blobs.set(target, url);\n  }\n  // No attributeFilter: it never matches namespaced attributes such as xlink:href.\n}).observe(document.getElementById(\"plot\"), { attributes: true, subtree: true });\n```\n\n### Environment\n- plotly.js 4.1.1 and 4.0.0\n- Chromium 153.0.8010.12 and Edge WebView2 154.0.4258.37\n- Windows 11 (build 26200).\n\nNot tested in Firefox or Safari.\n","author":{"url":"https://github.com/JeS24","@type":"Person","name":"JeS24"},"datePublished":"2026-10-01T14:52:33Z","url":"https://github.com/plotly/plotly.js/issues/8097"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:fdb81279-159e-e3c1-8ddd-984df237073e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB34A:2270F4:28700A5:35B5CC8:6B01B081
html-safe-nonce5266f4ef6eaab26360a26cda28e4c00f5815e744f0af3c44ed713ffefa505307
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzRBOjIyNzBGNDoyODcwMEE1OjM1QjVDQzg6NkIwMUIwODEiLCJ2aXNpdG9yX2lkIjoiNDE5MjQzNjY5NTAyMTQ0NjQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac48c784efba4aee0e8a94af2a8b5c199ffc59ac10f128b9ea9d0de5ba6bb82eae
hovercard-subject-tagissue:5664183467
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.js/8097/issue_layout
twitter:imagehttps://opengraph.githubassets.com/981c86a5b5ea1413baa5e712182f75c4ffc8307d65032bf421966c929a15156f/plotly/plotly.js/issues/8097
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/981c86a5b5ea1413baa5e712182f75c4ffc8307d65032bf421966c929a15156f/plotly/plotly.js/issues/8097
og:image:altDescription Every heatmap redraw sets the trace's SVG to a fresh canvas.toDataURL('image/png') (src/traces/heatmap/plot.js#L369). In Chromium, these distinct data-URL image resources remain...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJeS24
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/plotly/plotly.js git https://github.com/plotly/plotly.js.git
octolytics-dimension-user_id5997976
octolytics-dimension-user_loginplotly
octolytics-dimension-repository_id45646037
octolytics-dimension-repository_nwoplotly/plotly.js
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id45646037
octolytics-dimension-repository_network_root_nwoplotly/plotly.js
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/plotly/plotly.js/issues/8097#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fplotly%2Fplotly.js%2Fissues%2F8097
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fplotly%2Fplotly.js%2Fissues%2F8097
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=plotly%2Fplotly.js
Reloadhttps://github.com/plotly/plotly.js/issues/8097
Reloadhttps://github.com/plotly/plotly.js/issues/8097
Reloadhttps://github.com/plotly/plotly.js/issues/8097
plotlyhttps://github.com/plotly
plotly.jshttps://github.com/plotly/plotly.js
Codehttps://github.com/plotly/plotly.js
Issues726 (726)https://github.com/plotly/plotly.js/issues
Pull requests84 (84)https://github.com/plotly/plotly.js/pulls
Actionshttps://github.com/plotly/plotly.js/actions
Security and qualityhttps://github.com/plotly/plotly.js/security
Insightshttps://github.com/plotly/plotly.js/insights
https://github.com/plotly/plotly.js
New issuehttps://github.com/login?return_to=https://github.com/plotly/plotly.js/issues/8097
New issuehttps://github.com/login?return_to=https://github.com/plotly/plotly.js/issues/8097
#8114https://github.com/plotly/plotly.js/pull/8114
[BUG]: Memory Leak - Heatmap redraws continuously grow Chromium renderer memory via unique PNG data: URLshttps://github.com/plotly/plotly.js/issues/8097#top
#8114https://github.com/plotly/plotly.js/pull/8114
P2considered for next cyclehttps://github.com/plotly/plotly.js/issues?q=state%3Aopen%20label%3A%22P2%22
bugsomething brokenhttps://github.com/plotly/plotly.js/issues?q=state%3Aopen%20label%3A%22bug%22
size: 1https://github.com/plotly/plotly.js/issues?q=state%3Aopen%20label%3A%22size%3A%201%22
https://github.com/JeS24
JeS24https://github.com/JeS24
on Oct 1, 2026https://github.com/plotly/plotly.js/issues/8097#issue-5664183467
src/traces/heatmap/plot.js#L369https://github.com/plotly/plotly.js/blob/v4.1.1/src/traces/heatmap/plot.js#L369
JeS24https://github.com/JeS24
bugsomething brokenhttps://github.com/plotly/plotly.js/issues?q=state%3Aopen%20label%3A%22bug%22
on Oct 1, 2026https://github.com/plotly/plotly.js/issues/8097#event-32262024646
https://github.com/camdecoster
camdecosterhttps://github.com/camdecoster
on Oct 1, 2026https://github.com/plotly/plotly.js/issues/8097#issuecomment-5938769765
camdecosterhttps://github.com/camdecoster
P2considered for next cyclehttps://github.com/plotly/plotly.js/issues?q=state%3Aopen%20label%3A%22P2%22
size: 1https://github.com/plotly/plotly.js/issues?q=state%3Aopen%20label%3A%22size%3A%201%22
on Oct 1, 2026https://github.com/plotly/plotly.js/issues/8097#event-32281581078
https://github.com/JeS24
JeS24https://github.com/JeS24
on Oct 2, 2026https://github.com/plotly/plotly.js/issues/8097#issuecomment-5951732122
https://github.com/camdecoster
camdecosterhttps://github.com/camdecoster
on Oct 6, 2026https://github.com/plotly/plotly.js/issues/8097#issuecomment-6023611130
https://github.com/JeS24
JeS24https://github.com/JeS24
on Oct 7, 2026https://github.com/plotly/plotly.js/issues/8097#issuecomment-6037557197
https://github.com/JeS24
JeS24https://github.com/JeS24
on Oct 10, 2026https://github.com/plotly/plotly.js/issues/8097#issuecomment-6091611468
@camdecosterhttps://github.com/camdecoster
#8114https://github.com/plotly/plotly.js/pull/8114
Sign up for freehttps://github.com/signup?return_to=https://github.com/plotly/plotly.js/issues/8097
Sign in to commenthttps://github.com/login?return_to=https://github.com/plotly/plotly.js/issues/8097
P2considered for next cyclehttps://github.com/plotly/plotly.js/issues?q=state%3Aopen%20label%3A%22P2%22
bugsomething brokenhttps://github.com/plotly/plotly.js/issues?q=state%3Aopen%20label%3A%22bug%22
size: 1https://github.com/plotly/plotly.js/issues?q=state%3Aopen%20label%3A%22size%3A%201%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.