@@ -184,7 +184,11 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
184
184
#endif
185
185
#if MEMORY_LIMIT
186
186
CHECK_MEMORY_LIMIT (size , SIZE );
187
+ if (AG (allocated_memory ) > AG (allocated_memory_peak )) {
188
+ AG (allocated_memory_peak ) = AG (allocated_memory );
189
+ }
187
190
#endif
191
+
188
192
HANDLE_UNBLOCK_INTERRUPTIONS ();
189
193
return (void * )((char * )p + sizeof (zend_mem_header ) + MEM_HEADER_PADDING );
190
194
}
@@ -304,7 +308,11 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LIN
304
308
#endif
305
309
#if MEMORY_LIMIT
306
310
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
+ }
307
314
#endif
315
+
308
316
p -> size = size ;
309
317
310
318
HANDLE_UNBLOCK_INTERRUPTIONS ();
@@ -389,6 +397,7 @@ ZEND_API void start_memory_manager(ALS_D)
389
397
AG (memory_limit ) = 1 <<30 ; /* rediculous limit, effectively no limit */
390
398
AG (allocated_memory ) = 0 ;
391
399
AG (memory_exhausted ) = 0 ;
400
+ AG (allocated_memory_peak ) = 0 ;
392
401
#endif
393
402
394
403
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)
487
496
}
488
497
#if MEMORY_LIMIT
489
498
AG (memory_exhausted )= 0 ;
499
+ AG (allocated_memory_peak ) = 0 ;
490
500
#endif
491
501
502
+
492
503
#if (ZEND_DEBUG )
493
504
do {
494
505
zval display_memory_cache_stats ;
0 commit comments