diff options
author | nagachika <nagachika@ruby-lang.org> | 2021-07-18 15:23:09 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2021-07-22 11:47:00 +0900 |
commit | a215c6d0448764131cbbb48b476dc698b51c2273 (patch) | |
tree | 93492686fdf93e14d7694f543bb872cb37543dbf /ractor.c | |
parent | c4b602e80fdc1824c68602302a4ed82a0e90d5b7 (diff) |
partially merge revision(s) 119697f61e2b2b157816a8aa33aada5863959900,4a627dbdfd1165022fa9e716ba845e937b03773d: [Backport #18014]
[Bug #18014] Fix rb_gc_force_recycle unmark before sweep
If we force recycle an object before the page is swept, we should clear
it in the mark bitmap. If we don't clear it in the bitmap, then during
sweeping we won't account for this free slot so the `free_slots` count
of the page will be incorrect.
---
gc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[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.
---
gc.c | 116 +++++++++++++++++++++++++++-------------------------------
internal/gc.h | 6 +++
ractor.c | 3 ++
ractor_core.h | 5 +--
4 files changed, 64 insertions(+), 66 deletions(-)
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
Diffstat (limited to 'ractor.c')
-rw-r--r-- | ractor.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -1443,6 +1443,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(); |