PHP Memory_get_usage and Memory_get_peak_usage differences

Source: Internet
Author: User
When viewing a process using the Linux command ps or TOP command, you can see the percentage and size of memory consumption, where the size is the same as the Memory_get_peak_usage

The method memory_get_usage refers to the memory that is being used by the current script

Reference http://us2.php.net/manual/en/function.memory-get-peak-usage.php

One is the system allocated memory, the other is the memory currently used by memory, for example:

1, the database read out thousands data, if said to consume 100MB, then the system will be allocated to process 100MB

2, when processing the data after unset off, in fact, the current process of the memory consumption does not become smaller, that is, will not release 100MB space

3, memory is divided into, "used" and "idle", unset will only "used" to "idle", the next memory request will go to "idle" to take

4, the program ends, the GC will release all memory

Unset can let Memory_get_peak_usage do not continue to rise, the program to execute the allocated memory (memory in the process) is still subject to memory_get_peak_usage

More

A) also refer to the title: in-depth discussion of memory management issues in PHP Learn more about PHP memory management

b) PDO Statement->execute () has placed the result set inside.

  • 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.