NYCPHP Meetup

NYPHP.org

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

Ben Sgro ben at projectskyline.com
Tue Apr 1 12:37:53 EDT 2008


Hello,

If anyone is truly interested in the internals of php (the c code and 
data structures) take a look at the book
"Extending and Embedding PHP". Its got lots of source.

If you don't know c, its not that helpful and will be a challenging read.

- Ben

Webmaster wrote:
> 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
>>
>>   
>
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>



More information about the talk mailing list