About php memory allocation. How to deal with it-php Tutorial

Source: Internet
Author: User
About php memory allocation. & Lt ;? Php $ tmemory_get_usage (); 3125000 $ i1; $ a [$ I] $ I; $ i11111111; $ a [$ I] $ I; $ i1; $ a [$ I] $ I; $ i111111111111111111111; $ a [$ I] $ I; echomemor about php memory allocation.

$ T = memory_get_usage ();
// 3125000

$ I = 1;
$ A [$ I] = $ I;

USD I = 1111111111;
$ A [$ I] = $ I;

$ I = '1 ';
$ A [$ I] = $ I;

$ I = '000000 ';
$ A [$ I] = $ I;


Echo memory_get_usage ()-$ t;

?>

How can I calculate the memory occupied by each component. Thank you.

------ Solution --------------------
Follow

Ci1699 is a good question.
------ Solution --------------------
Successive output and observation

The best way is to check how the variable table is constructed in the source code.
------ Solution --------------------
Php is c-based, and memory management is not oriented to php.
For this question, please refer to what laruence said.

Http://www.laruence.com/2011/03/04/1894.html

Http://www.laruence.com/2011/11/09/2277.html

------ Solution --------------------
You should use memory_get_usage (TRUE) for comparison. if both are replaced with TRUE, I guess the output is the same.

In essence, php has its own memory management mechanism, which requires a larger memory block for application.

Then there is a set of memory management structures to reduce the number of system calls
------ Solution --------------------
Discussion

Reference:

Php is c-based, and memory management is not oriented to php.
For this question, please refer to what laruence said.

Http://www.laruence.com/2011/03/04/1894.html

Http://www.laruence.com/2011/11/09/2277.html
To be honest, the articles mentioned in these articles are just a few minutes away.
......

------ Solution --------------------
I am not talking about how to apply for memory, but about how php maintains the variable table.
The php variable should be a structure queue, and each item should at least include: variable name, type, value pointer, whether it is referenced ....
This is what we need to care about, and how he maintains this table. But not very important
------ Solution --------------------
Discussion

I am not talking about how to apply for memory, but about how php maintains the variable table.
The php variable should be a structure queue, and each item should at least include: variable name, type, value pointer, whether it is referenced ....
This is what we need to care about, and how he maintains this table. But not very important

------ Solution --------------------
What a wonderful student ....


Discussion

Thank you, big brother upstairs.
Sina Cloud is sometimes really slow. It cannot be opened for a long time.


I am still tossing the sorting. Last night, I got three more = _ =
I want to use php bitmap for sorting, but it consumes too much memory.
Now we want to optimize it. Paste the code later.

------ Solution --------------------
The predecessors said, let's take a look. I got taught. thank you.
------ Solution --------------------
Laruence is a Chinese developer who went to the core of php.

Related Article

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.