I Added One Key to a PHP Array. It Cost 25 MB of Memory
SMRTR summary
PHP arrays switch between two internal layouts — a compact packed array and a full hash table — and the memory difference is dramatic. Adding a single string key to a million-element array jumps from 16.8 MB to 41.9 MB. Using typed classes instead of associative arrays for query rows cuts memory roughly in half, and streaming results with generators drops peak usage from 241 MB to 37 KB.
SMRTR provides this summary for quick context. The original article belongs to Daily.dev.
Read the original article