@@ -2274,7 +2274,9 @@ void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
22742274 /* Make sure the heap free below does not use tracked_free(). */
22752275 heap -> custom_heap .std ._free = free ;
22762276 }
2277+ #if ZEND_MM_STAT
22772278 heap -> size = 0 ;
2279+ #endif
22782280 }
22792281
22802282 if (full ) {
@@ -2820,6 +2822,7 @@ static zend_always_inline zval *tracked_get_size_zv(zend_mm_heap *heap, void *pt
28202822}
28212823
28222824static zend_always_inline void tracked_check_limit (zend_mm_heap * heap , size_t add_size ) {
2825+ #if ZEND_MM_STAT
28232826 if (add_size > heap -> limit - heap -> size && !heap -> overflow ) {
28242827#if ZEND_DEBUG
28252828 zend_mm_safe_error (heap ,
@@ -2831,6 +2834,7 @@ static zend_always_inline void tracked_check_limit(zend_mm_heap *heap, size_t ad
28312834 heap -> limit , add_size );
28322835#endif
28332836 }
2837+ #endif
28342838}
28352839
28362840static void * tracked_malloc (size_t size )
@@ -2844,7 +2848,9 @@ static void *tracked_malloc(size_t size)
28442848 }
28452849
28462850 tracked_add (heap , ptr , size );
2851+ #if ZEND_MM_STAT
28472852 heap -> size += size ;
2853+ #endif
28482854 return ptr ;
28492855}
28502856
@@ -2855,7 +2861,9 @@ static void tracked_free(void *ptr) {
28552861
28562862 zend_mm_heap * heap = AG (mm_heap );
28572863 zval * size_zv = tracked_get_size_zv (heap , ptr );
2864+ #if ZEND_MM_STAT
28582865 heap -> size -= Z_LVAL_P (size_zv );
2866+ #endif
28592867 zend_hash_del_bucket (heap -> tracked_allocs , (Bucket * ) size_zv );
28602868 free (ptr );
28612869}
@@ -2880,7 +2888,9 @@ static void *tracked_realloc(void *ptr, size_t new_size) {
28802888
28812889 ptr = __zend_realloc (ptr , new_size );
28822890 tracked_add (heap , ptr , new_size );
2891+ #if ZEND_MM_STAT
28832892 heap -> size += new_size - old_size ;
2893+ #endif
28842894 return ptr ;
28852895}
28862896
0 commit comments