3v4l.org

run code in 300+ PHP versions simultaneously
<?php // makes a big map $map = []; for($a = 0; $a < 55555; $a++){ $map["key" . $a] = (object)(array)["x" => $a]; } // empty the map (or partially empty it) for($a = 0; $a < 55555; $a++){ unset($map["key" . $a]); } // at this point $map's length is nexPow2(55555), even if it is empty $om = memory_get_usage(); echo $om . "\n"; (function(array $map){ $map["sup"] = "copy"; // copy on write allocates another nexPow2(55555) array, // rather than starting with a small one $nm = memory_get_usage(); echo $nm . "\n"; })($map);

Abusive script

This script was stopped while abusing our resources

Output for 7.2.4 - 7.2.5, 7.2.7 - 7.2.8, 7.2.10
3260088 5619816
Output for 7.1.15 - 7.1.16, 7.1.20, 7.2.3, 7.2.6, 7.2.9

Process exited with code 137.
Output for 7.1.17 - 7.1.19, 7.1.21 - 7.1.22
3223480 5583208
Output for 5.6.38
Parse error: syntax error, unexpected '(' in /in/Manqu on line 27
Process exited with code 255.

preferences:
52.28 ms | 409 KiB | 5 Q