Skip to content

fix(sync): clear __pw_stack__ on task completion to prevent memory le… - #3158

Closed
atiqur-rahman-pro wants to merge 1 commit into
microsoft:mainfrom
atiqur-rahman-pro:fix/sync-pw-stack-leak-3157
Closed

fix(sync): clear __pw_stack__ on task completion to prevent memory le…#3158
atiqur-rahman-pro wants to merge 1 commit into
microsoft:mainfrom
atiqur-rahman-pro:fix/sync-pw-stack-leak-3157

Conversation

@atiqur-rahman-pro

Copy link
Copy Markdown

Summary of Changes

In playwright/_impl/_sync_base.py, inspect.stack(0) is attached to task.__pw_stack__. Because live FrameInfo objects pin all caller local variables in memory, retaining the task causes a memory leak.

This PR updates task.add_done_callback to delete task.__pw_stack__ upon task completion, ensuring frame objects and local variables are garbage collected immediately.

Fixes #3157

@Skn0tt

Skn0tt commented Jul 30, 2026

Copy link
Copy Markdown
Member

Closing per #3157 (comment)

@Skn0tt Skn0tt closed this Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants