PHP Fatal error:? Allowed memory size of 134217728 bytes exhausted (tried to allocate 1441792 bytes) in /www/wwwroot/s-route/vendor/workerman/workerman/Connection/TcpConnection.php on line 372
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1441792 bytes) in /www/wwwroot/s-route/vendor/workerman/workerman/Connection/TcpConnection.php on line 372
Worker process terminated with ERROR: E_ERROR "Allowed memory size of 134217728 bytes exhausted (tried to allocate 1441792 bytes) in /www/wwwroot/s-route/vendor/workerman/workerman/Connection/TcpConnection.php on line 372"
?
求大佬看下這是內(nèi)存溢出導(dǎo)致的么?
有什么辦法解決么?
[attach]2042[/attach]
[attach]2043[/attach]
?
TcpConnection.php發(fā)生內(nèi)存報錯應(yīng)該是快速給所有客戶端發(fā)送大數(shù)據(jù)導(dǎo)致的,看報錯 tried to allocate 1441792 bytes
一個連接嘗試申請 1M+的內(nèi)存。如果快速地給很多客戶端推送數(shù)據(jù),客戶端又無法接收或無法及時接收(例如客戶端沒有接收,或切到后臺無法接收、服務(wù)器帶寬不夠等),這些數(shù)據(jù)都會積壓在內(nèi)存,導(dǎo)致內(nèi)存使用升高到php.ini設(shè)置的極限值報錯。
想象下給200連接同時推送1M的數(shù)據(jù),服務(wù)器瞬間帶寬需要1G+,如果服務(wù)器帶寬沒有這么大就會堆積在內(nèi)存,可能產(chǎn)生報錯。
解決辦法優(yōu)化業(yè)務(wù)不要發(fā)大數(shù)據(jù)或者不要一直無限制發(fā)送數(shù)據(jù),加大內(nèi)存,加大帶寬等。
當然如果內(nèi)存報錯不是發(fā)生在TcpConnection.php,可能是有其它問題。