summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--gc.c10
-rw-r--r--test/ruby/test_gc.rb11
3 files changed, 25 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 5964d548b4..3a2dd64585 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Wed Nov 27 15:05:59 2013 Koichi Sasada <ko1@atdot.net>
+
+ * gc.c (gc_stat): add new information heap_eden_page_length and
+ heap_tomb_page_length.
+
+ * test/ruby/test_gc.rb: fix to use GC.stat[:heap_eden_page_length]
+ instead of GC.stat[:heap_length].
+ This test expects `heap_eden_page_length' (used pages size).
+
Wed Nov 27 15:02:53 2013 Aman Gupta <ruby@tmm1.net>
* test/ruby/test_eval.rb (class TestEval): Use assert_same instead of
diff --git a/gc.c b/gc.c
index 7ceb534072..0f10ceb933 100644
--- a/gc.c
+++ b/gc.c
@@ -2742,6 +2742,11 @@ gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_
heap_pages_final_slots += final_slots;
sweep_page->final_slots = final_slots;
+ if (1) fprintf(stderr, "gc_page_sweep(%d): freed?: %d, limt: %d, freed_slots: %d, empty_slots: %d, final_slots: %d\n",
+ (int)rb_gc_count(),
+ final_slots + freed_slots + empty_slots == sweep_page->limit,
+ (int)sweep_page->limit, (int)freed_slots, (int)empty_slots, final_slots);
+
if (heap_pages_deferred_final && !finalizing) {
rb_thread_t *th = GET_THREAD();
if (th) {
@@ -5064,6 +5069,7 @@ gc_stat(int argc, VALUE *argv, VALUE self)
static VALUE sym_count;
static VALUE sym_heap_used, sym_heap_length, sym_heap_increment;
static VALUE sym_heap_live_slot, sym_heap_free_slot, sym_heap_final_slot, sym_heap_swept_slot;
+ static VALUE sym_heap_eden_page_length, sym_heap_tomb_page_length;
static VALUE sym_total_allocated_object, sym_total_freed_object;
static VALUE sym_malloc_increase, sym_malloc_limit;
#if USE_RGENGC
@@ -5090,6 +5096,8 @@ gc_stat(int argc, VALUE *argv, VALUE self)
S(heap_free_slot);
S(heap_final_slot);
S(heap_swept_slot);
+ S(heap_eden_page_length);
+ S(heap_tomb_page_length);
S(total_allocated_object);
S(total_freed_object);
S(malloc_increase);
@@ -5139,6 +5147,8 @@ gc_stat(int argc, VALUE *argv, VALUE self)
SET(heap_free_slot, objspace_free_slot(objspace));
SET(heap_final_slot, heap_pages_final_slots);
SET(heap_swept_slot, heap_pages_swept_slots);
+ SET(heap_eden_page_length, heap_eden->page_length);
+ SET(heap_tomb_page_length, heap_tomb->page_length);
SET(total_allocated_object, objspace->profile.total_allocated_object_num);
SET(total_freed_object, objspace->profile.total_freed_object_num);
SET(malloc_increase, malloc_increase);
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index 40c5b1471f..da4a0b585d 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -200,15 +200,16 @@ class TestGc < Test::Unit::TestCase
def test_expand_heap
assert_separately %w[--disable-gem], __FILE__, __LINE__, <<-'eom'
- base_length = GC.stat[:heap_length]
- (base_length * 500).times{ 'a' }
GC.start
- assert_equal base_length, GC.stat[:heap_length], "invalid heap expanding"
+ base_length = GC.stat[:heap_eden_page_length]
+ (base_length * 500).times{ 'a'; nil }
+ GC.start
+ assert_equal base_length, GC.stat[:heap_eden_page_length], "invalid heap expanding"
a = []
- (base_length * 500).times{ a << 'a' }
+ (base_length * 500).times{ a << 'a'; nil }
GC.start
- assert base_length < GC.stat[:heap_length]
+ assert base_length < GC.stat[:heap_eden_page_length]
eom
end
end