Currently my app uses around 7 MB memory.
The array appears to use 700 KB if I check it size with strlen(serialize($array)))).
-
If use this array within my app, and check memory usage (with
memory_get_peak_usage()) I get 14 MB. -
If I don’t use it, I get 7 MB.
If this array takes 700 KB serialized, why does PHP need 7 MB for this variable? Or am I doing the benchmark the wrong way?
You wanna steer away from PHP if this bothers you: http://nikic.github.com/2011/12/12/How-big-are-PHP-arrays-really-Hint-BIG.html. PHP arrays just like some living space.
When possible you could use
SplFixedArray, but then again who cares about what space a PHP array takes. If you are looking for clean / performance stuff why are you using PHP in the first place (yes this is coming from a PHP guy) 🙂