Mysql-php stole my memory.

Source: Internet
Author: User
Tags phpinfo
$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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.