News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Nikic's Blog:
How big are PHP arrays (and values) really? (Hint BIG!)
December 16, 2011 @ 10:28:39

In this recent blog post nikic takes an in-depth look at how large PHP arrays really are - how memory is used in the creation and management of these handy PHP variable types.

In this post I want to investigate the memory usage of PHP arrays (and values in general) using the following script as an example, which creates 100000 unique integer array elements and measures the resulting memory usage. [...] How much would you expect it to be? [...] Now try and run the above code. You can do it online if you want. This gives me 14649024 bytes. Yes, you heard right, that's 13.97 MB - eightteen times more than we estimated.

He goes into the details of PHP's memory management and breaks it down into the different totals (for 64 bit and 32 bit OSes) and details on each - zvalue_value, zvalue, cycles collector, Zend MM allocator and the buckets used to isolate one array (hash table/dictionary) from another.

What does this tell us? PHP ain't C. That's all this should tell us. You can't expect that a super dynamic language like PHP has the same highly efficient memory usage that C has. You just can't.
0 comments voice your opinion now!
memory management array datatype backend c


blog comments powered by Disqus

Similar Posts

Blue Parabola Blog: Magento Feature Analysis Series, Part 7: Order Management Offering

ProDevTips Blog: Fluent Arrays and Strings in PHP

ProDevTips Blog: Fluent Arrays and Strings in PHP - Adding JSON and more

Edd Mann: Storing PHP Sessions/File Caches in Memory using TMPFS

Rdavid.net: Test Results on Memory Usage of Zend Framework and Doctrine with APC


Community Events





Don't see your event here?
Let us know!


developer library series list language configure unittest podcast threedevsandamaybe community release introduction interview laravel wordpress application code framework api install

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework