diff options
author | John Hawthorn <john@hawthorn.email> | 2024-02-11 21:43:38 -0800 |
---|---|---|
committer | John Hawthorn <john@hawthorn.email> | 2024-02-20 18:55:00 -0800 |
commit | 1c97abaabae6844c861705fd07f532292dcffa74 (patch) | |
tree | a1d5dbac7eab32f6ffc168f1e556dfac085bc89a /gc.c | |
parent | 2a6917b463fa4065f26aea44802e2e24cc494e4c (diff) |
De-dup identical callinfo objects
Previously every call to vm_ci_new (when the CI was not packable) would
result in a different callinfo being returned this meant that every
kwarg callsite had its own CI.
When calling, different CIs result in different CCs. These CIs and CCs
both end up persisted on the T_CLASS inside cc_tbl. So in an eval loop
this resulted in a memory leak of both types of object. This also likely
resulted in extra memory used, and extra time searching, in non-eval
cases.
For simplicity in this commit I always allocate a CI object inside
rb_vm_ci_lookup, but ideally we would lazily allocate it only when
needed. I hope to do that as a follow up in the future.
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -3745,6 +3745,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj) case imemo_callinfo: { const struct rb_callinfo * ci = ((const struct rb_callinfo *)obj); + rb_vm_ci_free(ci); if (ci->kwarg) { ((struct rb_callinfo_kwarg *)ci->kwarg)->references--; if (ci->kwarg->references == 0) xfree((void *)ci->kwarg); |