SMRTR ProgrammingSep 14, 2026Daily.dev

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
SMRTR Programming

Get the next batch of curated stories in your inbox.

This archive is built from SMRTR newsletter stories. Subscribe for hand-picked stories without the extra noise.

Related Stories

Browse Programming
ProgrammingSep 14, 2026

Encore for Python

Encore.py lets Python developers declare cloud infrastructure directly in code, while platform teams keep full control over environment-specific configuration.