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.

Closes GH-7745.
This commit is contained in:
Christoph M. Becker 2021-12-09 15:36:26 +01:00
parent 0ac3d78d7d
commit 5675ebe649
No known key found for this signature in database
GPG Key ID: D66C9593118BCCB6
2 changed files with 4 additions and 2 deletions

2
NEWS
View File

@ -4,6 +4,8 @@ PHP NEWS
- Core:
. Fixed bug #81656 (GCC-11 silently ignores -R). (Michael Wallner)
. Fixed bug #81585 (cached_chunks are not counted to real_size on shutdown).
(cmb)
- Spl:
. Fixed bug #75917 (SplFileObject::seek broken with CSV flags). (Aliaksandr

View File

@ -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;