$m1 = memory_get_usage();var_dump($m1);$arr = array_fill(0, 100000, 'phpinfo');unset($arr);$m2 = memory_get_usage();var_dump($m2);var_dump("消耗内存:".($m2-$m1)/1000);
The output is: string (21) "Consumes Memory: 64.688";
I am puzzled that I have used unset for large arrays, where 64.688K of memory is taken out of which to run, solving
Reply content:
$m1 = memory_get_usage();var_dump($m1);$arr = array_fill(0, 100000, 'phpinfo');unset($arr);$m2 = memory_get_usage();var_dump($m2);var_dump("消耗内存:".($m2-$m1)/1000);
The output is: string (21) "Consumes Memory: 64.688";
I am puzzled that I have used unset for large arrays, where 64.688K of memory is taken out of which to run, solving
< <深入理解php内存管理之谁动了我的内存> >
Http://www.laruence.com/2011/03/04/1894.html
PHP is not simply to the OS to memory, but will be like the OS to a chunk of memory, and then assign one piece to the applicant, so when there is logic to apply for memory,
It is no longer necessary to request memory from the OS, and frequent system calls are avoided.
When we call efree
to free memory, PHP will not return the memory to the OS, but it will put the memory into the list of free memory maintained by itself. And for small chunks of memory,
More likely, put it in the memory cache list (PostScript, some versions of PHP, such as my verified PHP5.2.4, 5.2.6, 5.2.8,
At get_memory_usage()
the time of invocation, the available memory block size in the memory cache list is not subtracted, causing the memory to appear unset
unchanged later