Skip to content

Don't use a shared closure for each spawned thread - #27

Open
awilfox wants to merge 1 commit into
okcomputer-ruby:mainfrom
awilfox:awilfox/parallel-no-shared-closure
Open

Don't use a shared closure for each spawned thread#27
awilfox wants to merge 1 commit into
okcomputer-ruby:mainfrom
awilfox:awilfox/parallel-no-shared-closure

Conversation

@awilfox

@awilfox awilfox commented Aug 4, 2026

Copy link
Copy Markdown

I identified a memory leak in a long-running Rails app using OkComputer and found it only triggered when check_in_parallel was true.

Codex found the bug, but I authored the patch myself based on its analysis. I did not accept its initial suggestion.

--

Using a closure here keeps the immediate environment 'live', which means all thread objects are accessible to all other threads. This compounded a memory leak scenario in timeout which was keeping a single thread alive – in an app with 10 checks, it would leak all 10 threads instead of just the one with the timeout issue.

I identified a memory leak in a long-running Rails app using OkComputer
and found it only triggered when `check_in_parallel` was `true`.

Codex found the bug, but I authored the patch myself based on its
analysis.  I did not accept its initial suggestion.
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.

1 participant