From c2fa49a9b453621dbe80630f3be88223fe10ab29 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 17 Jul 1998 05:12:48 +0000 Subject: 1.1c0 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- gc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gc.c') diff --git a/gc.c b/gc.c index e6b001fca1..934b00ec80 100644 --- a/gc.c +++ b/gc.c @@ -42,8 +42,10 @@ static void run_final(); #define GC_MALLOC_LIMIT 200000 #endif #endif +#define GC_NEWOBJ_LIMIT 1000 static unsigned long malloc_memories = 0; +static unsigned long alloc_objects = 0; void * xmalloc(size) @@ -56,7 +58,7 @@ xmalloc(size) } if (size == 0) size = 1; malloc_memories += size; - if (malloc_memories > GC_MALLOC_LIMIT) { + if (malloc_memories > GC_MALLOC_LIMIT && alloc_objects > GC_NEWOBJ_LIMIT) { gc_gc(); } mem = malloc(size); @@ -94,9 +96,6 @@ xrealloc(ptr, size) } if (!ptr) return xmalloc(size); malloc_memories += size; - if (malloc_memories > GC_MALLOC_LIMIT) { - gc_gc(); - } mem = realloc(ptr, size); if (!mem) { gc_gc(); @@ -253,6 +252,7 @@ rb_newobj() retry: obj = (VALUE)freelist; freelist = freelist->as.free.next; + alloc_objects++; return obj; } if (dont_gc) add_heap(); @@ -621,6 +621,7 @@ gc_sweep() freed += n; freelist = nfreelist; } + alloc_objects = 0; if (freed < FREE_MIN) { add_heap(); } -- cgit v1.2.3