]> granicus.if.org Git - php/commitdiff
Make GC default threshold handling consistent
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 23 Oct 2020 08:30:07 +0000 (10:30 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 23 Oct 2020 08:30:07 +0000 (10:30 +0200)
While the initial threshold is set to 10001 roots, the threshold
adjustment logic may then set it to 10000. The exact value really
doesn't matter, but we should make it consistent.

Zend/zend_gc.c

index aa9602ff044719623ec788d25ce0e95dc666e6e1..bfc124719cc2d194cb39334bd3ad1e0e782bcfe8 100644 (file)
 #define GC_MAX_UNCOMPRESSED  (512 * 1024)
 #define GC_MAX_BUF_SIZE      0x40000000
 
-#define GC_THRESHOLD_DEFAULT 10000
+#define GC_THRESHOLD_DEFAULT (10000 + GC_FIRST_ROOT)
 #define GC_THRESHOLD_STEP    10000
 #define GC_THRESHOLD_MAX     1000000000
 #define GC_THRESHOLD_TRIGGER 100
@@ -501,7 +501,7 @@ ZEND_API zend_bool gc_enable(zend_bool enable)
                GC_G(buf) = (gc_root_buffer*) pemalloc(sizeof(gc_root_buffer) * GC_DEFAULT_BUF_SIZE, 1);
                GC_G(buf)[0].ref = NULL;
                GC_G(buf_size) = GC_DEFAULT_BUF_SIZE;
-               GC_G(gc_threshold) = GC_THRESHOLD_DEFAULT + GC_FIRST_ROOT;
+               GC_G(gc_threshold) = GC_THRESHOLD_DEFAULT;
                gc_reset();
        }
        return old_enabled;