diff options
author | Gannon McGibbon <[email protected]> | 2024-03-22 15:40:42 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2024-03-26 13:53:00 -0400 |
commit | 4bdb79618b33422551e96723827e50ab20e9abb1 () | |
tree | 164dd7030ca35384c6699983cec2dca271451313 /vm_backtrace.c | |
parent | 4300c42a7eb12a0aa81e4ec79891cdba1cfdf3aa (diff) |
Mark frame info structs with rb_gc_mark_movable
Using rb_gc_mark_movable and a reference update function, we can make frame infos movable in memory, and avoid pinning frame info backtraces. ``` require "objspace" exceptions = [] GC.disable 50_000.times do begin raise "some exception" rescue => exception exception.backtrace_locations exceptions << exception end end GC.enable GC.compact p ObjectSpace.dump_all(output: :string).lines.grep(/"pinned":true/).count ``` Co-authored-by: Peter Zhu <[email protected]>
-rw-r--r-- | vm_backtrace.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -134,7 +134,14 @@ static void location_mark(void *ptr) { struct valued_frame_info *vfi = (struct valued_frame_info *)ptr; - rb_gc_mark(vfi->btobj); } static void @@ -150,6 +157,7 @@ static const rb_data_type_t location_data_type = { location_mark, RUBY_TYPED_DEFAULT_FREE, NULL, // No external memory to report, }, 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE }; |