The cost of a million objects – revisited for PHP7

PHP 7 is out there finally and I am sure the adoption rate will be very slow especially because of legacy code.

Here is a repetition of my simple tests I’ve done before (PHP Memory Usage: The cost of a million objects) and comparison of those results between PHP 5.6.18 and PHP 7.0.3.

path-to-php5/php.exe test-path/memory_test_v4_objects_with_myclass_simple.php
path-to-php7/php.exe test-path/memory_test_v4_objects_with_myclass_simple.php

php-memory-usage-chart-php-7

I think, this shows that PHP 7 will use less memory (almost half in this test) and run faster (almost twice in this test), but I am concerned about the leftover memory, which is also almost 4 times the memory usage on PHP 5 (after removing objects and running garbage collection).

Leave a Comment