Huge array takes more memory space than it should

Viewed 400

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?

2 Answers
Related