3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Memory leak somewhere around __set? class A { var $data = array(); function __get($k) { return $this->data[$k]; } function __set($k, $v) { return $this->data[$k] = $v; } } $b = new A(); for ($i = 0; $i < 500000; $i++) $b->{"a$i"} = 'abc'; var_dump(memory_get_usage()); // int(78318488) - why so big? $c = clone $b; unset($b); var_dump(memory_get_usage()); // int(42220972) - OK unset($c); $b = new A(); for ($i = 0; $i < 500000; $i++) $b->__set("a$i", 'abc'); var_dump(memory_get_usage()); // int(42221492) - OK
Output for 7.4.0 - 7.4.1
int(37361760) int(37361792) int(37361792)
Output for 7.3.0 - 7.3.13
int(37361688) int(37361720) int(37361720)
Output for 7.2.0 - 7.2.26
int(35260872) int(35260904) int(35260904)
Output for 7.1.0 - 7.1.1, 7.1.3, 7.1.6 - 7.1.33
int(35224328) int(35224360) int(35224360)
Output for 5.6.31 - 5.6.32, 7.1.2, 7.1.5

Process exited with code 137.
Output for 7.1.4
int(35224328) int(35224360)
Process exited with code 137.
Output for 7.0.0 - 7.0.3, 7.0.5 - 7.0.14, 7.0.16 - 7.0.33
int(58098808) int(35224392) int(35224392)
Output for 7.0.4, 7.0.15
int(58098808) int(35224392)
Process exited with code 137.
Output for 5.3.0 - 5.3.29, 5.4.10 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 5.6.33 - 5.6.40
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 79 bytes) in /in/l4e7n on line 21
Process exited with code 255.
Output for 5.4.0 - 5.4.9
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/l4e7n on line 21
Process exited with code 255.
Output for 5.2.6 - 5.2.17
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 79 bytes) in /in/l4e7n on line 14
Process exited with code 255.
Output for 5.2.1 - 5.2.5
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 5 bytes) in /in/l4e7n on line 21
Process exited with code 255.
Output for 5.1.3 - 5.1.6, 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/l4e7n on line 22
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.1 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/l4e7n on line 7 Fatal error: Call to undefined function memory_get_usage() in /in/l4e7n on line 22
Process exited with code 255.
Output for 5.1.0
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/l4e7n on line 7 Fatal error: fatal flex scanner internal error--end of buffer missed in /in/l4e7n on line 31
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_VARIABLE in /in/l4e7n on line 23
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_VARIABLE in /in/l4e7n on line 23
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/l4e7n on line 23
Process exited with code 255.

preferences:
222.71 ms | 401 KiB | 325 Q