mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* gc.c: Improve accuracy of objspace_live_num() and
allocated/freed counters. patched by tmm1(Aman Gupta). [Bug #8092] [ruby-core:53392] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1bc93a1591
commit
80329d3a66
3 changed files with 16 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
|||
Tue Mar 19 00:26:22 2013 Narihiro Nakamura <authornari@gmail.com>
|
||||
|
||||
* gc.c: Improve accuracy of objspace_live_num() and
|
||||
allocated/freed counters. patched by tmm1(Aman Gupta).
|
||||
[Bug #8092] [ruby-core:53392]
|
||||
|
||||
Mon Mar 18 21:42:48 2013 Narihiro Nakamura <authornari@gmail.com>
|
||||
|
||||
* gc.c: Avoid unnecessary heap growth. patched by tmm1(Aman Gupta).
|
||||
|
|
10
gc.c
10
gc.c
|
@ -1431,12 +1431,10 @@ finalize_list(rb_objspace_t *objspace, RVALUE *p)
|
|||
while (p) {
|
||||
RVALUE *tmp = p->as.free.next;
|
||||
run_final(objspace, (VALUE)p);
|
||||
objspace->total_freed_object_num++;
|
||||
if (!FL_TEST(p, FL_SINGLETON)) { /* not freeing page */
|
||||
add_slot_local_freelist(objspace, p);
|
||||
if (!is_lazy_sweeping(objspace)) {
|
||||
objspace->total_freed_object_num++;
|
||||
objspace->heap.free_num++;
|
||||
}
|
||||
objspace->heap.free_num++;
|
||||
}
|
||||
else {
|
||||
struct heaps_slot *slot = (struct heaps_slot *)(VALUE)RDATA(p)->dmark;
|
||||
|
@ -1940,9 +1938,9 @@ slot_sweep(rb_objspace_t *objspace, struct heaps_slot *sweep_slot)
|
|||
else {
|
||||
sweep_slot->free_next = NULL;
|
||||
}
|
||||
objspace->total_freed_object_num += freed_num;
|
||||
objspace->heap.free_num += freed_num + empty_num;
|
||||
}
|
||||
objspace->total_freed_object_num += freed_num;
|
||||
objspace->heap.final_num += final_num;
|
||||
|
||||
if (deferred_final_list && !finalizing) {
|
||||
|
@ -2969,11 +2967,11 @@ rb_gc_force_recycle(VALUE p)
|
|||
rb_objspace_t *objspace = &rb_objspace;
|
||||
struct heaps_slot *slot;
|
||||
|
||||
objspace->total_freed_object_num++;
|
||||
if (MARKED_IN_BITMAP(GET_HEAP_BITMAP(p), p)) {
|
||||
add_slot_local_freelist(objspace, (RVALUE *)p);
|
||||
}
|
||||
else {
|
||||
objspace->total_freed_object_num++;
|
||||
objspace->heap.free_num++;
|
||||
slot = add_slot_local_freelist(objspace, (RVALUE *)p);
|
||||
if (slot->free_next == NULL) {
|
||||
|
|
|
@ -64,6 +64,12 @@ class TestGc < Test::Unit::TestCase
|
|||
assert_equal(arg, res)
|
||||
assert_equal(false, res.empty?)
|
||||
assert_kind_of(Integer, res[:count])
|
||||
|
||||
stat, count = {}, {}
|
||||
GC.start
|
||||
GC.stat(stat)
|
||||
ObjectSpace.count_objects(count)
|
||||
assert_equal(count[:TOTAL]-count[:FREE], stat[:heap_live_num])
|
||||
end
|
||||
|
||||
def test_singleton_method
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue