Skip to content

Commit 31d4b82

Browse files
author
Andi Gutmans
committed
- MFH
1 parent a715a08 commit 31d4b82

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Zend/zend_alloc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,11 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
184184
#endif
185185
#if MEMORY_LIMIT
186186
CHECK_MEMORY_LIMIT(size, SIZE);
187+
if (AG(allocated_memory) > AG(allocated_memory_peak)) {
188+
AG(allocated_memory_peak) = AG(allocated_memory);
189+
}
187190
#endif
191+
188192
HANDLE_UNBLOCK_INTERRUPTIONS();
189193
return (void *)((char *)p + sizeof(zend_mem_header) + MEM_HEADER_PADDING);
190194
}
@@ -304,7 +308,11 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LIN
304308
#endif
305309
#if MEMORY_LIMIT
306310
CHECK_MEMORY_LIMIT(size - p->size, SIZE - REAL_SIZE(p->size));
311+
if (AG(allocated_memory) > AG(allocated_memory_peak)) {
312+
AG(allocated_memory_peak) = AG(allocated_memory);
313+
}
307314
#endif
315+
308316
p->size = size;
309317

310318
HANDLE_UNBLOCK_INTERRUPTIONS();
@@ -389,6 +397,7 @@ ZEND_API void start_memory_manager(ALS_D)
389397
AG(memory_limit) = 1<<30; /* rediculous limit, effectively no limit */
390398
AG(allocated_memory) = 0;
391399
AG(memory_exhausted) = 0;
400+
AG(allocated_memory_peak) = 0;
392401
#endif
393402

394403
memset(AG(fast_cache_list_head), 0, sizeof(AG(fast_cache_list_head)));
@@ -487,8 +496,10 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
487496
}
488497
#if MEMORY_LIMIT
489498
AG(memory_exhausted)=0;
499+
AG(allocated_memory_peak) = 0;
490500
#endif
491501

502+
492503
#if (ZEND_DEBUG)
493504
do {
494505
zval display_memory_cache_stats;

0 commit comments

Comments
 (0)