René's URL Explorer Experiment


Title: fix(memory): close app-service leak paths behind the per-task memory ramp by icecrasher321 · Pull Request #7056 · simstudioai/sim · GitHub

Open Graph Title: fix(memory): close app-service leak paths behind the per-task memory ramp by icecrasher321 · Pull Request #7056 · simstudioai/sim

X Title: fix(memory): close app-service leak paths behind the per-task memory ramp by icecrasher321 · Pull Request #7056 · simstudioai/sim

Description: Problem App-service memory climbs monotonically with task uptime and resets only on deploy, with the worst tasks approaching the task memory limit between deploys. MemoryTelemetry shows the growth lives in the main Next.js process (its RSS accounts for essentially the entire container ramp) — not the isolated-vm sandbox worker, which is a separate child process with a bounded pool (4 workers, retired at 200 executions) and finally-guaranteed isolate disposal on every path. Fixes Copilot stream teardown backstop (lib/copilot/request/lifecycle/start.ts) — the activeStreams registration, the 250 ms Redis abort poller, and the SSE keepalive were acquired outside the finally that releases them, so a throw that bypassed the ordered teardown (e.g. resetBuffer on a Redis blip at stream start) orphaned two immortal intervals and the registration for the life of the process. An idempotent, flag-guarded backstop in the orchestration's existing outer finally now releases them on every path. Client-visible error behavior is unchanged (the backstop deliberately does not close the stream), and the chat-stream lock release is ownership-guarded so a successor stream's lock can never be touched. Large-value cache sweep + idle-TTL LRU (lib/execution/payloads/cache.ts) — expiry was enforced only inside later cache calls, so a quieting instance held expired parsed object graphs indefinitely; a self-retiring, unref'd 60 s sweep now keeps the TTL honest. Lifetimes are also now idle-based (every authorized read refreshes expiry and moves the entry to the back of the eviction order), so a value a live run keeps referencing can never expire or be pressure-evicted mid-use — strictly fewer mid-execution misses. TTL values, the admission budget, and the sole-copy (recoverable: false) eviction protection are unchanged. BYOK rotation cursors (lib/api-key/byok.ts) — the tenant-keyed cursor Map had no delete/TTL/ceiling; now an LRUCache({ max: 10_000 }). Evicting an idle pool's cursor just restarts rotation at index 0, which the per-instance approximate-rotation contract already tolerates. Collab-doc jsdom singleton (lib/collab-doc/converter.ts) — the DOM guard read the bundled module's window binding while the install wrote globalThis.window (the same bundler mismatch next.config.ts documents for TipTap), so a runtime where the two disagree allocated a fresh multi-MB jsdom window on every conversion. Guard and install now both use globalThis, and the window is a module singleton either way. Telemetry (lib/monitoring/memory-telemetry.ts) — the Memory snapshot now includes largeValueCacheEntries/largeValueCacheTrackedMB (reads the JSON-vs-heap amplification directly against heapUsedMB) and detachedContexts. Verification 436 tests across 30 files (copilot session + lifecycle, payloads, collab-doc, byok, function-execute route, streaming), including new regression tests for the early-throw release and the retention policy. tsc and biome clean. A local before/after repro harness (env-gated vitest suites with synthetic load, run on pre-fix staging and on this branch; deliberately not committed) measured: Probe Pre-fix staging This branch 200 streams failing at session reset → registrations still alive 200 / 200 leaked 0 / 200 47 MB tracked (≈128 MB heap) cached, traffic stops, 16 min idle 0 MB reclaimed while idle 124 MB reclaimed during idle The harness also measured the JSON-bytes → retained-heap amplification of parsed graphs at 2.2–2.7×, i.e. the cache's 256 MB nominal budget pins a small multiple of that in real heap. Tightening that accounting changes admission semantics (more storeLargeValue failures when durable storage is down), so it is deliberately not part of this PR — the new telemetry sizes it first. 🤖 Generated with Claude Code

Open Graph Description: Problem App-service memory climbs monotonically with task uptime and resets only on deploy, with the worst tasks approaching the task memory limit between deploys. MemoryTelemetry shows the growth ...

X Description: Problem App-service memory climbs monotonically with task uptime and resets only on deploy, with the worst tasks approaching the task memory limit between deploys. MemoryTelemetry shows the growth ...

Opengraph URL: https://github.com/simstudioai/sim/pull/7056

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:74c288e6-d419-588b-a70e-94541495956c
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE794:487EF:B3B8EB:F7B845:6AFB549E
html-safe-nonce4af0f56e8065060c1b558510e16f57d4d1583a59f00f7bfd1771d1005241c173
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzk0OjQ4N0VGOkIzQjhFQjpGN0I4NDU6NkFGQjU0OUUiLCJ2aXNpdG9yX2lkIjoiODQxNTA2ODY5ODMwNTA1Nzk1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacff4bc346a1c297ff1d4b291f83c8bc56e283cdcf2490058f9552ac8ab10b3959
hovercard-subject-tagpull_request:4353998566
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/7056/files
twitter:imagehttps://avatars.githubusercontent.com/u/17950982?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/17950982?s=400&v=4
og:image:altProblem App-service memory climbs monotonically with task uptime and resets only on deploy, with the worst tasks approaching the task memory limit between deploys. MemoryTelemetry shows the growth ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecbf66c024bb6d10e6955baa7413c54cf13a201bb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/7056/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F7056%2Ffiles
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%2Fsimstudioai%2Fsim%2Fpull%2F7056%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/7056/files
Reloadhttps://github.com/simstudioai/sim/pull/7056/files
Reloadhttps://github.com/simstudioai/sim/pull/7056/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests197 (197)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
icecrasher321https://github.com/icecrasher321
staginghttps://github.com/simstudioai/sim/tree/staging
fix/app-memory-leakshttps://github.com/simstudioai/sim/tree/fix/app-memory-leaks
Conversation 7 https://github.com/simstudioai/sim/pull/7056
Commits 2 https://github.com/simstudioai/sim/pull/7056/commits
Checks 31 https://github.com/simstudioai/sim/pull/7056/checks
Files changed https://github.com/simstudioai/sim/pull/7056/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/7056/files
fix(memory): close app-service leak paths behind the per-task memory ramp https://github.com/simstudioai/sim/pull/7056/files#top
Show all changes 2 commits https://github.com/simstudioai/sim/pull/7056/files
c6a7acf fix(memory): close app-service leak paths behind the per-task memory … Aug 25, 2026 https://github.com/simstudioai/sim/pull/7056/commits/c6a7acfccabd5a54cda5b2c0d1d9c61458f1a5be
f203584 improvement(execution): idle-TTL touch-on-read + LRU eviction for the… Aug 25, 2026 https://github.com/simstudioai/sim/pull/7056/commits/f2035842b7a61c1cff64d145c3a3dc6b2f32846e
Clear filters https://github.com/simstudioai/sim/pull/7056/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/7056/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/7056/files
byok.ts https://github.com/simstudioai/sim/pull/7056/files#diff-c005b3d5176372adb521b659913d6ef6fed32b3380cfb8b20b33f7e7c7490c69
converter.ts https://github.com/simstudioai/sim/pull/7056/files#diff-af9ae168e904ab94029cdb84b88c938a1a1db45b5af96dbd2f9ac1e244875825
start.test.ts https://github.com/simstudioai/sim/pull/7056/files#diff-5cb534d5e4152427cf216ad071d600bedfaaea4562a0d5120046c839983f42dc
start.ts https://github.com/simstudioai/sim/pull/7056/files#diff-6d1d121ff4ddd703b0fe2a11c19ce949a7d3d0532e5e7c84bb0fecb2e8e48f8e
cache.test.ts https://github.com/simstudioai/sim/pull/7056/files#diff-de08fd02c7448f67d885d17e35ce4426242af43415c70280a7557d91d01f4531
cache.ts https://github.com/simstudioai/sim/pull/7056/files#diff-42e85cfef430ab900927ed39b89b6537e631bddc29e5a80cb2b7a80575b7d2d9
memory-telemetry.ts https://github.com/simstudioai/sim/pull/7056/files#diff-4761667416bf1597878349434033c1dc36c695122e8f99e4a2941feee107cea2
apps/sim/lib/api-key/byok.tshttps://github.com/simstudioai/sim/pull/7056/files#diff-c005b3d5176372adb521b659913d6ef6fed32b3380cfb8b20b33f7e7c7490c69
View file https://github.com/simstudioai/sim/blob/f2035842b7a61c1cff64d145c3a3dc6b2f32846e/apps/sim/lib/api-key/byok.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/7056/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/7056/files#diff-c005b3d5176372adb521b659913d6ef6fed32b3380cfb8b20b33f7e7c7490c69
https://github.com/simstudioai/sim/pull/7056/files#diff-c005b3d5176372adb521b659913d6ef6fed32b3380cfb8b20b33f7e7c7490c69
https://github.com/simstudioai/sim/pull/7056/files#diff-c005b3d5176372adb521b659913d6ef6fed32b3380cfb8b20b33f7e7c7490c69
apps/sim/lib/collab-doc/converter.tshttps://github.com/simstudioai/sim/pull/7056/files#diff-af9ae168e904ab94029cdb84b88c938a1a1db45b5af96dbd2f9ac1e244875825
View file https://github.com/simstudioai/sim/blob/f2035842b7a61c1cff64d145c3a3dc6b2f32846e/apps/sim/lib/collab-doc/converter.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/7056/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/7056/files#diff-af9ae168e904ab94029cdb84b88c938a1a1db45b5af96dbd2f9ac1e244875825
https://github.com/simstudioai/sim/pull/7056/files#diff-af9ae168e904ab94029cdb84b88c938a1a1db45b5af96dbd2f9ac1e244875825
https://github.com/simstudioai/sim/pull/7056/files#diff-af9ae168e904ab94029cdb84b88c938a1a1db45b5af96dbd2f9ac1e244875825
apps/sim/lib/copilot/request/lifecycle/start.test.tshttps://github.com/simstudioai/sim/pull/7056/files#diff-5cb534d5e4152427cf216ad071d600bedfaaea4562a0d5120046c839983f42dc
View file https://github.com/simstudioai/sim/blob/f2035842b7a61c1cff64d145c3a3dc6b2f32846e/apps/sim/lib/copilot/request/lifecycle/start.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/7056/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/7056/files#diff-5cb534d5e4152427cf216ad071d600bedfaaea4562a0d5120046c839983f42dc
https://github.com/simstudioai/sim/pull/7056/files#diff-5cb534d5e4152427cf216ad071d600bedfaaea4562a0d5120046c839983f42dc
https://github.com/simstudioai/sim/pull/7056/files#diff-5cb534d5e4152427cf216ad071d600bedfaaea4562a0d5120046c839983f42dc
https://github.com/simstudioai/sim/pull/7056/files#diff-5cb534d5e4152427cf216ad071d600bedfaaea4562a0d5120046c839983f42dc
https://github.com/simstudioai/sim/pull/7056/files#diff-5cb534d5e4152427cf216ad071d600bedfaaea4562a0d5120046c839983f42dc
https://github.com/simstudioai/sim/pull/7056/files#diff-5cb534d5e4152427cf216ad071d600bedfaaea4562a0d5120046c839983f42dc
https://github.com/simstudioai/sim/pull/7056/files#diff-5cb534d5e4152427cf216ad071d600bedfaaea4562a0d5120046c839983f42dc
apps/sim/lib/copilot/request/lifecycle/start.tshttps://github.com/simstudioai/sim/pull/7056/files#diff-6d1d121ff4ddd703b0fe2a11c19ce949a7d3d0532e5e7c84bb0fecb2e8e48f8e
View file https://github.com/simstudioai/sim/blob/f2035842b7a61c1cff64d145c3a3dc6b2f32846e/apps/sim/lib/copilot/request/lifecycle/start.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/7056/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/7056/files#diff-6d1d121ff4ddd703b0fe2a11c19ce949a7d3d0532e5e7c84bb0fecb2e8e48f8e
https://github.com/simstudioai/sim/pull/7056/files#diff-6d1d121ff4ddd703b0fe2a11c19ce949a7d3d0532e5e7c84bb0fecb2e8e48f8e
https://github.com/simstudioai/sim/pull/7056/files#diff-6d1d121ff4ddd703b0fe2a11c19ce949a7d3d0532e5e7c84bb0fecb2e8e48f8e
https://github.com/simstudioai/sim/pull/7056/files#diff-6d1d121ff4ddd703b0fe2a11c19ce949a7d3d0532e5e7c84bb0fecb2e8e48f8e
https://github.com/simstudioai/sim/pull/7056/files#diff-6d1d121ff4ddd703b0fe2a11c19ce949a7d3d0532e5e7c84bb0fecb2e8e48f8e
https://github.com/simstudioai/sim/pull/7056/files#diff-6d1d121ff4ddd703b0fe2a11c19ce949a7d3d0532e5e7c84bb0fecb2e8e48f8e
https://github.com/simstudioai/sim/pull/7056/files#diff-6d1d121ff4ddd703b0fe2a11c19ce949a7d3d0532e5e7c84bb0fecb2e8e48f8e
apps/sim/lib/execution/payloads/cache.test.tshttps://github.com/simstudioai/sim/pull/7056/files#diff-de08fd02c7448f67d885d17e35ce4426242af43415c70280a7557d91d01f4531
View file https://github.com/simstudioai/sim/blob/f2035842b7a61c1cff64d145c3a3dc6b2f32846e/apps/sim/lib/execution/payloads/cache.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/7056/{{ revealButtonHref }}
Please reload this pagehttps://github.com/simstudioai/sim/pull/7056/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/7056/files
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.