From: SASADA Koichi Date: 2013-10-04T08:52:02+09:00 Subject: [ruby-core:57645] Re: [ruby-trunk - Bug #8983][Assigned] [PATCH] GC.stat[:heap_free_num] returns number of unused slots on heap (2013/10/03 18:29), naruse (Yui NARUSE) wrote: > https://github.com/tmm1/ruby/compare/gc-stat-free-num.patch One point. > @@ -1787,6 +1791,7 @@ struct os_each_struct { > else { > struct heap_slot *slot = (struct heap_slot *)(VALUE)RDATA(p)->dmark; > slot->limit--; > + heap_limit--; > } > p = tmp; > } Should not reduce heap_limit here. > @@ -2343,6 +2348,7 @@ struct force_finalize_list { > RDATA(pp)->dmark = (void (*)(void *))(VALUE)sweep_slot; > pp->as.free.flags |= FL_SINGLETON; /* freeing page mark */ > } > + heap_limit -= (freed_num + empty_num); > sweep_slot->limit = final_num; > unlink_heap_slot(objspace, sweep_slot); > } Should set "heap_limit -= slot->limit". This slot is already unavaialble from Ruby level. -- // SASADA Koichi at atdot dot net