diff options
author | Peter Zhu <peter@peterzhu.ca> | 2021-06-29 14:32:50 -0400 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2021-07-15 11:48:52 -0400 |
commit | 4a627dbdfd1165022fa9e716ba845e937b03773d (patch) | |
tree | 2dd5c738728ffb2e64816f8a4ffefc82acdc38aa /ractor.c | |
parent | 119697f61e2b2b157816a8aa33aada5863959900 (diff) |
[Bug #18014] Fix memory leak in GC when using Ractors
When a Ractor is removed, the freelist in the Ractor cache is not
returned to the GC, leaving the freelist permanently lost. This commit
recycles the freelist when the Ractor is destroyed, preventing a memory
leak from occurring.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4613
Diffstat (limited to 'ractor.c')
-rw-r--r-- | ractor.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -1486,6 +1486,9 @@ vm_remove_ractor(rb_vm_t *vm, rb_ractor_t *cr) } vm->ractor.cnt--; + /* Clear the cached freelist to prevent a memory leak. */ + rb_gc_ractor_newobj_cache_clear(&cr->newobj_cache); + ractor_status_set(cr, ractor_terminated); } RB_VM_UNLOCK(); |