diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-12-29 14:51:22 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-12-29 14:51:22 +0000 |
commit | 05b990b7c1aa0403e01c8a2f1da59392731d1f84 (patch) | |
tree | 19be2ba424759dc93554f442a79f8931d270e3d8 /gc.c | |
parent | 0569c8422c566d77f33843a5e11d87b0066e93a5 (diff) |
* gc.c (gc_sweep): adjust GC trigger.
* dln.c (init_funcname_len): get rid of gcc-3 -O3 warning.
* eval.c (copy_node_scope): ditto.
* hash.c (rb_hash_foreach, delete_if_i, select_i, each_value_i,
each_key_i, each_pair_i, envix): ditto.
* range.c (range_each_func): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 33 |
1 files changed, 5 insertions, 28 deletions
@@ -879,7 +879,7 @@ gc_sweep() RVALUE *p, *pend, *final_list; int freed = 0; int i, j; - unsigned long live = 0; + unsigned long live = 0, garbage = 0; if (ruby_in_compile && ruby_parser_stack_on_heap()) { /* should not reclaim nodes during compilation @@ -929,32 +929,7 @@ gc_sweep() } else { RBASIC(p)->flags &= ~FL_MARK; - live += sizeof(VALUE); - switch (BUILTIN_TYPE(p)) { - case T_OBJECT: - live += size_of_table(ROBJECT(p)->iv_tbl); - break; - case T_CLASS: - case T_ICLASS: - live += size_of_table(RCLASS(p)->iv_tbl); - live += size_of_table(RCLASS(p)->m_tbl); - break; - case T_STRING: - live += RSTRING(p)->len+1; - break; - case T_ARRAY: - live += RARRAY(p)->len * sizeof(VALUE); - break; - case T_HASH: - live += size_of_table(RHASH(p)->tbl); - break; - case T_BIGNUM: - live += RBIGNUM(p)->len * sizeof(BDIGIT); - break; - case T_STRUCT: - live += RSTRUCT(p)->len * sizeof(VALUE); - break; - } + live++; } p++; } @@ -971,7 +946,9 @@ gc_sweep() freed += n; } } - malloc_limit = live; + malloc_limit += malloc_increase; + malloc_limit *= (double)live / (live + freed); + if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT; malloc_increase = 0; if (freed < FREE_MIN) { add_heap(); |