概要
ObjectSpace#garbage_collect(full_mark: true, immediate_sweep: true) -> nil
詳細
参照されなくなったオブジェクトを回収する。
GC.start と同じ。
サンプルコード
require 'tbpgr_utils' bulk_puts_eval binding, <<-EOS GC.count ObjectSpace.garbage_collect GC.count GC.start GC.count EOS __END__ 下記はTbpgrUtils gemの機能 bulk_puts_eval https://rubygems.org/gems/tbpgr_utils https://github.com/tbpgr/tbpgr_utils
出力
GC.count # => 10 ObjectSpace.garbage_collect # => nil GC.count # => 11 GC.start # => nil GC.count # => 12