The system runs a long-running daemon script that scans the Redis queue every minute and enters logic when the condition is met, but every time it three hours, the system will get an error.
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in /data/Db.php on line 150
Check the number of frequent error lines, found that most of the PDO's execute or Fetch_all method error.
At the beginning of the SQL query is a problem, looked at the SQL statement is generally used with limit to take 10 records, and if it is a query statement problem will only make the query slow, not overflow ah.
Read the online information, most people say is to actively recycle memory, that is, using unset to use the object or variable to recycle. However, as a process, its logic is the same every time, and then the variable or object even if it is not recycled, it will be the next logical requirement of the same name variable overwrite Ah, if the first logic run through, the back should not overflow ah.
Ask the great God to help analyze my ideas where there is a problem, thank you.
Reply content:
The system runs a long-running daemon script that scans the Redis queue every minute and enters logic when the condition is met, but every time it three hours, the system will get an error.
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in /data/Db.php on line 150
Check the number of frequent error lines, found that most of the PDO's execute or Fetch_all method error.
At the beginning of the SQL query is a problem, looked at the SQL statement is generally used with limit to take 10 records, and if it is a query statement problem will only make the query slow, not overflow ah.
Read the online information, most people say is to actively recycle memory, that is, using unset to use the object or variable to recycle. However, as a process, its logic is the same every time, and then the variable or object even if it is not recycled, it will be the next logical requirement of the same name variable overwrite Ah, if the first logic run through, the back should not overflow ah.
Ask the great God to help analyze my ideas where there is a problem, thank you.
Scan every minute why not make crontab, so every time after execution exit, should not encounter memory problems it?
Can try to monitor the memory in each row of the changes, after two cycles to look at, have tried before in a loop even if the variable is released or will slowly increment up the memory consumption
Limit script memory consumption and time-out