Skip to content

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

Merged
emmahsax merged 2 commits into
okcomputer-ruby:mainfrom
awilfox:awilfox/parallel-no-shared-closure
Aug 7, 2026
Merged

Don't use a shared closure for each spawned thread#27
emmahsax merged 2 commits into
okcomputer-ruby:mainfrom
awilfox:awilfox/parallel-no-shared-closure

Conversation

@awilfox

@awilfox awilfox commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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.

awilfox and others added 2 commits August 4, 2026 13:30
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.
@emmahsax
emmahsax merged commit 9dac630 into okcomputer-ruby:main Aug 7, 2026
70 checks passed
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