Echoing content sometimes takes a very long time

前端 未结 8 2020
眼角桃花
眼角桃花 2021-02-19 16:20

I have a script that builds my webpage in one string ($content) and then echo it to the user.

My script looks like this:

$time1= microtime(true);
$conten         


        
8条回答
  •  春和景丽
    2021-02-19 16:31

    My guess is that the act of accessing that large of a string takes up a decent amount of memory over multiple uses. Because PHP is garbage collected, memory is taken up until the garbage collecter is ran, then it's freed. My guess is that multiple requests to store content in a string variable is causing the rapid filling up of volatile memory (RAM). Then a few times a day you start hitting the limit causing the slower load times. Garbage collecter hits, and everything is back to normal.

提交回复
热议问题