summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-07-17 05:12:48 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-07-17 05:12:48 +0000
commitc2fa49a9b453621dbe80630f3be88223fe10ab29 (patch)
treeb7c9e8cc04031fd40639c05c2e96544d80934c1b /gc.c
parent20e305950e9fb53e1b1cb338f9b04b1be43fd7bb (diff)
1.1c0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c9
1 files changed, 5 insertions, 4 deletions
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();
}