diff --git a/ChangeLog b/ChangeLog index 6a2d6c19a9..9f18ab4fa4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Nov 4 08:11:19 2007 Tanaka Akira + + * gc.c (count_objects): count TOTAL. + Sun Nov 4 03:58:32 2007 Yukihiro Matsumoto * string.c (tr_setup_table): use C array for characters that fit diff --git a/gc.c b/gc.c index 331723aacc..09a3417730 100644 --- a/gc.c +++ b/gc.c @@ -2155,7 +2155,8 @@ rb_obj_id(VALUE obj) * * Counts objects for each type. * - * It returns a hash as: {:FREE=>3012, :T_OBJECT=>6, :T_CLASS=>404, ...} + * It returns a hash as: + * {:TOTAL=>10000, :FREE=>3011, :T_OBJECT=>6, :T_CLASS=>404, ...} * * If the optional argument, result_hash, is given, * it is overwritten and returned. @@ -2173,6 +2174,7 @@ count_objects(int argc, VALUE *argv, VALUE os) { long counts[T_MASK+1]; long freed = 0; + long total = 0; int i; VALUE hash; @@ -2197,10 +2199,12 @@ count_objects(int argc, VALUE *argv, VALUE os) freed++; } } + total += heaps[i].limit; } if (hash == Qnil) hash = rb_hash_new(); + rb_hash_aset(hash, ID2SYM(rb_intern("TOTAL")), LONG2NUM(total)); rb_hash_aset(hash, ID2SYM(rb_intern("FREE")), LONG2NUM(freed)); for (i = 0; i <= T_MASK; i++) { VALUE type;