Skip to content

Commit 5675ebe

Browse files
committed
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.
1 parent 0ac3d78 commit 5675ebe

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ PHP NEWS
44

55
- Core:
66
. Fixed bug #81656 (GCC-11 silently ignores -R). (Michael Wallner)
7+
. Fixed bug #81585 (cached_chunks are not counted to real_size on shutdown).
8+
(cmb)
79

810
- Spl:
911
. Fixed bug #75917 (SplFileObject::seek broken with CSV flags). (Aliaksandr

Zend/zend_alloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,10 +2303,10 @@ void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
23032303
#endif
23042304
memset(heap->free_slot, 0, sizeof(heap->free_slot));
23052305
#if ZEND_MM_STAT || ZEND_MM_LIMIT
2306-
heap->real_size = ZEND_MM_CHUNK_SIZE;
2306+
heap->real_size = (heap->cached_chunks_count + 1) * ZEND_MM_CHUNK_SIZE;
23072307
#endif
23082308
#if ZEND_MM_STAT
2309-
heap->real_peak = ZEND_MM_CHUNK_SIZE;
2309+
heap->real_peak = (heap->cached_chunks_count + 1) * ZEND_MM_CHUNK_SIZE;
23102310
#endif
23112311
heap->chunks_count = 1;
23122312
heap->peak_chunks_count = 1;

0 commit comments

Comments
 (0)