Skip to content

fix: clear descriptorTargetMap on unmount to prevent memory leak - #1705

Open
498755303 wants to merge 2 commits into
jd-opensource:devfrom
498755303:fix/descriptor-target-map-leak
Open

fix: clear descriptorTargetMap on unmount to prevent memory leak#1705
498755303 wants to merge 2 commits into
jd-opensource:devfrom
498755303:fix/descriptor-target-map-leak

Conversation

@498755303

Copy link
Copy Markdown

Background

descriptorTargetMap in src/sandbox/with/window.ts records an entry for
every property whose descriptor is queried through the proxy window
(getOwnPropertyDescriptor), but it is never cleared.

Under repeated mount/unmount (keep-alive, prerender) the map grows without
bound, and it may also hold stale routing targets across app lifecycles.

Change

  • Lift descriptorTargetMap from createProxyWindow to the patchWindow scope.
  • Pass it into both createProxyWindow and patchWindowEffect.
  • Clear it in release() on unmount (outside the clearTimer branch, so it is
    cleared in every unmount mode).

Notes

No behavior change for a mounted app; only frees the cache on unmount.

raoenhui and others added 2 commits June 25, 2026 18:32
descriptorTargetMap accumulates an entry per property whose descriptor
is queried through the proxy window (getOwnPropertyDescriptor), but was
never cleared. Under repeated mount/unmount (keep-alive, prerender) the
map grows without bound and may hold stale routing targets.

Lift the map to patchWindow scope, pass it to createProxyWindow and
patchWindowEffect, and clear it in release() on every unmount mode.
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

Successfully merging this pull request may close these issues.

2 participants