From 90326f6d9969c92ac32b917eac1100bd88ec287c Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 9 Dec 2021 15:36:26 +0100 Subject: [PATCH] Fix #81585: cached_chunks are not counted to real_size on shutdown The amount of allocated system memory is kept in `real_size`, including the allocated `cached_chunks`. Thus, we need to keep the proper count at the end of the shutdown. --- Zend/zend_alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 0d3e41776d732..5738c030a5822 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -2303,10 +2303,10 @@ void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent) #endif memset(heap->free_slot, 0, sizeof(heap->free_slot)); #if ZEND_MM_STAT || ZEND_MM_LIMIT - heap->real_size = ZEND_MM_CHUNK_SIZE; + heap->real_size = (heap->cached_chunks_count + 1) * ZEND_MM_CHUNK_SIZE; #endif #if ZEND_MM_STAT - heap->real_peak = ZEND_MM_CHUNK_SIZE; + heap->real_peak = (heap->cached_chunks_count + 1) * ZEND_MM_CHUNK_SIZE; #endif heap->chunks_count = 1; heap->peak_chunks_count = 1;