summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-20 02:06:42 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-20 02:06:42 +0000
commite75c34c2e9f9e1c629cdab13c0c400494f49adb7 (patch)
tree7cc376d79d80b16b340be2219a6f80e69826a303 /gc.c
parent0014687097c3c0ce8e728496ad7fa777372ea7fb (diff)
* gc.c (gc_sweep): loosen page free condition to avoid add_heap()
race condition. [ruby-dev:21633] * gc.c (gc_sweep): do not update malloc_limit when malloc_increase is smaller than malloc_limit. * ext/socket/socket.c (make_hostent): h_aliases may be NULL. (ruby-bugs PR#1195) * ext/socket/socket.c (sock_s_gethostbyaddr): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gc.c b/gc.c
index b3200d2927..4bbcf09a94 100644
--- a/gc.c
+++ b/gc.c
@@ -969,7 +969,7 @@ gc_sweep()
}
p++;
}
- if (n == heaps[i].limit && freed + n > FREE_MIN) {
+ if (n == heaps[i].limit && freed > FREE_MIN) {
RVALUE *pp;
heaps[i].limit = 0;
@@ -982,8 +982,10 @@ gc_sweep()
freed += n;
}
}
- malloc_limit += (malloc_increase - malloc_limit) * (double)live / (live + freed);
- if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT;
+ if (malloc_increase > malloc_limit) {
+ 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();