Bug #70341 [NEW]: Weird behaviour of memory_get and peak_usage

From: Date: Mon, 24 Aug 2015 12:42:11 +0000
Subject: Bug #70341 [NEW]: Weird behaviour of memory_get and peak_usage
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195469@lists.php.net to get a copy of this message
From: quantuumsnot at gmail dot com Operating system: windows 7 x64 PHP version: 7.0.0RC1 Package: *General Issues Bug Type: Bug Bug description:Weird behaviour of memory_get and peak_usage Description: ------------ I usually use this short script to test some home-brew functions but noticed a inconsistency in memory_get_usage() and memory_get_peak_usage() Corresponding to docs, when using: FALSE parameter - emalloc() returns bytes used by the script TRUE parameter - returns bytes allocated by OS The problem is that the script worked on PHP 5.6.8 x64 Thread Safe - returned bytes are above 0, but in 7.0.0RC1 this returns 0 The fix is to use at line #1 memory_get_usage(false) which returns 40-50 times!!! bigger memory usage (for example 1.6-1.8MB instead of 40-45KB) Tested it on 3v4l.org and the results are the same, 5.5.0-5.6.12 always win What is the correct way to benchmark my code in PHP7 using pure PHP? (do not suggest xdebug or frameworks, please) Test script: --------------- $memoryUsage = memory_get_peak_usage(false); someFunctionCalled(); $memoryUsage = abs(memory_get_peak_usage(false) - $memoryUsage); -- Edit bug report at https://bugs.php.net/bug.php?id=70341&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70341&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70341&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70341&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70341&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70341&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70341&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70341&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70341&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70341&r=support Expected behavior: https://bugs.php.net/fix.php?id=70341&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70341&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70341&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70341&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70341&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70341&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70341&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70341&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70341&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70341&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70341&r=mysqlcfg

« previous php.bugs (#195469) next »