NYCPHP Meetup

NYPHP.org

[nycphp-talk] Did you know that each integer in a PHP array takes 68 bytes of storage?

Michael B Allen ioplex at gmail.com
Tue Apr 1 11:17:16 EDT 2008


On 4/1/08, Sol Toure <sol2ray at gmail.com> wrote:
> Good to know:
> http://pankaj-k.net/weblog/2008/03/did_you_know_that_each_integer.html

I don't understand. Is this supposed to indicate that PHP is somehow
inefficient at storing array elements?

"a single integer value stored within an PHP array uses 68 bytes: 16
bytes for value structure (zval), 36 bytes for hash bucket, and 2*8 =
16 bytes for memory allocation headers."

That sounds fairly reasonable to me.

Note that each element does not incur a hash bucket. The bucket holds
a list. The blogger just wasn't smart enough to insert enough elements
to see elements hash to the same bucket.

Mike

-- 
Michael B Allen
PHP Active Directory SPNEGO SSO
http://www.ioplex.com/



More information about the talk mailing list