Programming

Programming

— Software development, languages, tools, and the craft of building software
1 members Created Sep 2026

I Added One Key to a PHP Array. It Cost 25 MB of Memory

Pinned in General
dev.to/nazar-boyko/i-added-one-key-to-a-php-array-it-cost-25-mb-of-memory-4b80
General · @curator · 2d ago ·

In PHP 8.4, a packed array of one million integers consumes approximately 16.78 bytes per element, but adding a single string key converts it to a hash table structure that requires 41.94 bytes per element—roughly 2.5 times more memory—because PHP must then store keys, hashes, and index structures instead of relying on implicit sequential indexing.

— via dev.to, Nazar Boyko

1

No comments yet

Be the first to share your thoughts.

Report thread

Why are you reporting this thread?

Restore the redacted content?

This will make it visible to everyone again. The clear action is logged in the mod log.