In general, the memory utilization of the PHP array is only 1/10, that is, a C language inside the 100M memory array, in PHP 1G is necessary. In particular, in the system of PHP as a background server, there are often problems with memory costs too much. Because this is a language problem, conventional solutions are more difficult to solve. The following is a scenario that is solved by string.
$total = 100000; $double = ""; for ($i = 0; $i < $total; $i + +) { $double. = Pack ("D", $i + 0.1);} for ($i = 0; $i < $total; $i + +) { unpack ("@"). ($i * 8). "/d", $double);}
This example saves an array of double strings with a string. Then unpack out when it's in use.
Of course, this can affect performance. To see the specific needs.
For example, in this case:
You have 10 arrays, each of which is 10M (about 1 million data), then 10 takes 100M of memory.
Plus 10 people in parallel, the memory will be serious enough.
Then, in 10 arrays, not all are used at the same time. You can, save them as a string and then, when used, unpack a string into an array.
Related recommendations:
PHP Array Memory Utilization Low detailed analysis
PHP array memory consuming too many problems solution _php
Resolving PHP array memory consumption too much