NYCPHP Meetup

NYPHP.org

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

Webmaster consult at covenantedesign.com
Tue Apr 1 11:26:46 EDT 2008


You're not the only one that isn't following the inference/point here.

What would be an example of a real-life application of array usage that 
would be rendered faulty/unstable due to this limitation?

Michael B Allen wrote:
> 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
>
>   





More information about the talk mailing list