mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
Fix memory leak of Ractor basket when sending to closed Ractor
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
This commit is contained in:
parent
a74c385208
commit
d55c463d56
Notes:
git
2025-06-12 14:02:57 +00:00
@ -1197,6 +1197,7 @@ ractor_send_basket(rb_execution_context_t *ec, const struct ractor_port *rp, str
|
||||
RUBY_DEBUG_LOG("closed:%u@r%u", (unsigned int)ractor_port_id(rp), rb_ractor_id(rp->r));
|
||||
|
||||
if (raise_on_error) {
|
||||
ractor_basket_free(b);
|
||||
rb_raise(rb_eRactorClosedError, "The port was already closed");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user