Skip to content

Fix memory leak of Ractor basket when sending to closed Ractor #13590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2025

Conversation

peterzhu2118
Copy link
Member

The following script leaks memory:

r = Ractor.new { }
r.value

10.times do
  100_000.times do
    r.send(123)
  rescue Ractor::ClosedError
  end

  puts `ps -o rss= -p #{$$}`
end

Before:

18508
25420
32460
40012
47308
54092
61132
68300
75724
83020

After:

11432
11432
11432
11432
11432
11432
11432
11432
11432
11688

The following script leaks memory:

    r = Ractor.new { }
    r.value

    10.times do
      100_000.times do
        r.send(123)
      rescue Ractor::ClosedError
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    18508
    25420
    32460
    40012
    47308
    54092
    61132
    68300
    75724
    83020

After:

    11432
    11432
    11432
    11432
    11432
    11432
    11432
    11432
    11432
    11688
@peterzhu2118 peterzhu2118 merged commit d55c463 into ruby:master Jun 12, 2025
91 of 93 checks passed
@peterzhu2118 peterzhu2118 deleted the ractor-basket-leak branch June 12, 2025 14:02
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