summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--gc.c10
-rw-r--r--test/ruby/test_gc.rb6
-rw-r--r--version.h2
4 files changed, 17 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 9c525fbb24..fdfde97e22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun Apr 7 02:54:40 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]
+
Fri Apr 5 00:54:08 2013 NARUSE, Yui <naruse@ruby-lang.org>
* ext/openssl/ossl_bn.c (ossl_bn_initialize): fix can't create from bn.
diff --git a/gc.c b/gc.c
index ace7a0882a..4831669dc7 100644
--- a/gc.c
+++ b/gc.c
@@ -1426,12 +1426,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;
@@ -1935,9 +1933,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) {
@@ -2961,11 +2959,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) {
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index 793ef3918e..62ae7ae5be 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -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
diff --git a/version.h b/version.h
index 16cdd32234..4117f34802 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2013-04-07"
-#define RUBY_PATCHLEVEL 107
+#define RUBY_PATCHLEVEL 108
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 4