# Memory usage and big arrays

- Thread: https://externals.io/message/28160
- Original archive: https://news-web.php.net/php.internals/28160
- Started by Brian Moon on 2007-02-26T20:05:01+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #28160 — Brian Moon — 2007-02-26T20:05:01+00:00

URL: https://externals.io/message/28160#28160

I was doing some testing with some cache files we use and found some 
shocking memory usage with big arrays.  Basically, when creating a large 
array in a verbose manner using $CATEGORIES[2]["name"] = "foo"; syntax, 
the memory usage was much higher than other methods.  For the particular 
file I was using, it was 5MB (verbose code) vs. 1.1MB (var_export 
format) vs. 900k (serialized).

All my test code is at http://dev.phorum.org/bigarray.tar.gz and more 
details are in my blog post at 
http://doughboy.wordpress.com/2007/02/26/big-arrays-in-php/.

I didn't want to post this to the bug list as I don't know that it is a 
bug.  This may be expected behavior.  But, I figured it would not hurt 
to point it out.  Maybe something obvious can be done to fix this?  I am 
not an advanced C coder or I would dig in to the code myself.

-- 

Brian Moon
-------------
http://dealnews.com/
It's good to be cheap =)
