Verify that the phpsession and array capacity is controlled by the memory size configured in php.

Source: Internet
Author: User
I personally verified that the capacity of phpsession and array is controlled by the memory size configured in php. after a function is completed today, many arrays are used, so I am eager to figure out the size of the php array and session, in fact, I mainly want to verify that the size of the array I heard is related to configuration. I personally verify that the size of the php session and array is controlled by the size of the memory configured in php.

After completing a function today, I used a large number of arrays, so I was eager to figure out the size of the php array and session, in fact, I mainly want to verify that the array capacity I have heard is correct with the configuration.

Array verification code program:

$ Arr = array (); // This line can be omitted. I prefer to follow the principle of first declaration and then use in java.
For ($ I = 0; I I <8000000; $ I ++ ){
$ Arr [$ I] = $ I;
}

Echo count ($ arr );
Unset ($ arr );

Session verification code program:

Ession_start ();
For ($ I = 0; I I <8000000; $ I ++ ){
$ _ SESSION [$ I] = $ I;
}

Echo count ($ _ SESSION );

After running the above program, the following error message is displayed:

Note: in php. ini, the memory_limit value is 10 MB.



Then, my verification method is to set php. in ini, the value of memory_limit is changed to 1000 M. then, restart apache and run the verification program again. then, the value of array and session can be normally output.


Isn't it because I modified php. ini? is it because of other coincidences? I want to verify again if it is php. in ini, memory_limit is configured. I reset the value to 10 M, restart apache, and run the verification program again. The result is indeed an exception in memory insufficiency. Now I believe that the size of array and session is indeed related to the memory_limit configuration in php. ini.
However, the maximum size of this value is 1300 MB. after the verification program is run, my computer is almost dormant:


The above is only my personal verification point of view and is only for sharing and use. the verification method must be insufficient. thank you for your guidance.

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.