com php-src: Fixed incorrect "peak" memory consumption calculation.: Zend/zend_alloc.c

From: Date: Tue, 27 Oct 2015 01:20:54 +0000
Subject: com php-src: Fixed incorrect "peak" memory consumption calculation.: Zend/zend_alloc.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89538@lists.php.net to get a copy of this message
Commit: 5bfade4d40b457c83495d17e37d326aa64192382 Author: Dmitry Stogov <dmitry@zend.com> Tue, 13 Oct 2015 15:20:17 +0300 Committer: Anatol Belski <ab@php.net> Tue, 27 Oct 2015 02:20:54 +0100 Parents: a3af1b664b1e6cb72de9e5052e2dce034d13a861 Branches: PHP-7.0.0 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5bfade4d40b457c83495d17e37d326aa64192382 Log: Fixed incorrect "peak" memory consumption calculation. Changed paths: M Zend/zend_alloc.c Diff: diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index e04dc6a..6120efc 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -1507,7 +1507,9 @@ static void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size, si heap->real_size += new_size - old_size; #endif #if ZEND_MM_STAT + heap->real_peak = MAX(heap->real_peak, heap->real_size); heap->size += new_size - old_size; + heap->peak = MAX(heap->peak, heap->size); #endif #if ZEND_DEBUG zend_mm_change_huge_block_size(heap, ptr, new_size, real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); @@ -1618,9 +1620,19 @@ static void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size, si } /* Naive reallocation */ +#if ZEND_MM_STAT + do { + size_t orig_peak = heap->peak; + size_t orig_real_peak = heap->real_peak; +#endif ret = zend_mm_alloc_heap(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); memcpy(ret, ptr, MIN(old_size, copy_size)); zend_mm_free_heap(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); +#if ZEND_MM_STAT + heap->peak = MAX(orig_peak, heap->size); + heap->real_peak = MAX(orig_real_peak, heap->real_size); + } while (0); +#endif return ret; }

« previous php.cvs (#89538) next »