3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A extends \stdClass { public int $i = 42; } $holder = []; for ($i = 0; $i < 10000; $i++) { $holder[] = new A; } var_dump(memory_get_usage()); foreach ($holder as $obj) { } var_dump(memory_get_usage()); $unserialized_holder = []; foreach ($holder as $obj) { $unserialized_holder[] = \unserialize(\serialize($obj)); } unset($holder); var_dump(memory_get_usage());
Output for 8.2.0 - 8.2.14, 8.3.0 - 8.3.1
int(1338176) int(1338208) int(5229336)
Output for 8.1.0 - 8.1.27
int(1600624) int(1600656) int(5491784)

preferences:
47.28 ms | 406 KiB | 5 Q