We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

View Complete Thread
  • Re: PHP 7.2 on IIS extremely slooow . string concat, but everything else works great??!

    Mar 13, 2019 02:28 AM|Elendil Zheng|LINK

    Hi niceblue

    I'm not an expert of PHP but I can provide my advise

    the echo just flushes buffer to the output stream, all memory it uses is the buffer, so no memory leak would be there

    on the other hand .concat, I searched this in bing and it seems in PHP string is mutable, just think what it will happen while you are calling a .concat function under the surface(of course that is based on my understanding of what most language would do)

    1. Check if the buffer that assigned to current string is long enough to store the appended content (you memory allocated to the current string is 1k in serial, 0.8k is used)

    2. If not, Find a piece of memory that is long enough to store the new string and double the buffer size(you want to .concat another 0.5k size string to the current string, while only 0.2k is left, so system looks for another piece of memory whose size is 2K to store your new string)

    3. Copy the current string to the new memory address 

    4. during this phase, if memory limitation was met, some of the data would be stored in Virtual Memory, which will result to missing page interruption, and finally goes to an IO operation

    So basically the .concat would leads to high memory cost and a potential of memory fragmentation while in echo you are just using buffer size memory and no more memory was allocated

    I would suggest that you can do a  quick monitor of your php applicaiton against IO and Memory allocation by opening Task Manager, click Performance Tab, at the bottom, click the Open Resource Monitor,  than find your PHP process and track the IO and Memory data to find out the bottleneck 

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.