3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NonLeakingClass { protected $x=[1,2,3,4,5,6,7,8,9,10]; public function __counstruct(){ } } class NonLeakingClass2 { protected $x=[1,2,3,4,5,6,7,8,9,10]; public function __counstruct(){ } } function test($x){ $ret = []; for($i=0;$i<(1022/2)*$x;$i++){ $ret[] = new NonLeakingClass(); $ret[] = new NonLeakingClass2(); } return $ret; } echo "Test empty object memory leakage" . PHP_EOL; // WARNING: Uncomment this line and PHP stops to leak memory on object creation, strange :) for ($h = 1; $h < 5; $h++) { echo "test $h \n\n"; var_dump(memory_get_usage(false)); $a = test($h); unset($a); gc_collect_cycles(); var_dump(memory_get_usage(false)); } exit;

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.3.120.0090.00615.04
7.3.110.0090.00615.30
7.3.100.0030.01315.18
7.3.90.0090.00615.27
7.3.80.0030.00615.34
7.3.70.0030.01315.28
7.3.60.0090.00615.37
7.3.50.0070.01115.07
7.3.40.0040.01115.09
7.3.30.0080.00414.98
7.3.20.0030.01016.71
7.3.10.0070.01016.67
7.3.00.0020.01216.68
7.2.240.0030.01315.27
7.2.230.0040.01215.57
7.2.220.0040.01115.56
7.2.210.0030.01215.34
7.2.200.0000.01515.28
7.2.190.0100.00315.35
7.2.180.0080.00515.21
7.2.170.0150.00015.41
7.2.160.0040.01115.46
7.2.150.0000.01416.93
7.2.140.0090.00617.07
7.2.130.0030.01216.78
7.2.120.0060.00916.79
7.2.110.0060.01016.63
7.2.100.0410.00916.26
7.2.90.0390.00816.20
7.2.80.0350.00916.13
7.2.70.0400.01016.44
7.2.60.0390.01116.43
7.2.50.0070.01316.47
7.2.40.0410.00916.53
7.2.30.0320.01016.49
7.2.20.0310.00716.46
7.2.10.0160.00716.26
7.2.00.0270.01016.33
7.1.330.0040.01415.78
7.1.320.0090.00316.00
7.1.310.0130.00615.90
7.1.300.0080.00615.93
7.1.290.0060.00915.80
7.1.280.0000.01415.76
7.1.270.0030.01315.95
7.1.260.0090.00615.98
7.1.250.0100.00615.81
7.1.220.1040.00714.43
7.1.210.2390.00313.87
7.1.200.0790.01013.99
7.1.190.0180.01114.19
7.1.180.0620.00714.39
7.1.170.0090.01314.19
7.1.160.1060.01314.24
7.1.150.0900.00913.91
7.1.140.0680.01114.35
7.1.130.0490.00314.18
7.1.120.0220.01114.05
7.1.110.0660.00714.20
7.1.100.0680.00314.11
7.1.90.1030.01314.13
7.1.80.0330.00614.15
7.1.70.1330.00314.40
7.1.60.1320.01932.16
7.1.50.0560.00932.31
7.1.40.0620.02332.39
7.1.30.1300.01032.13
7.1.20.0910.02232.40
7.1.10.0210.00314.45
7.1.00.0520.01314.34

preferences:
36.94 ms | 401 KiB | 5 Q