PHP運行錯最有效解決辦法Fatal error: Out of memory (allocated 6029312)
2024-05-04 23:34:51
供稿:網友
Fatal error: Out of memory (allocated 786432) (tried to allocate 98304 bytes) in H:/freehost/zhengbao2/web/includes/lib_common.php on line 744
疑問:786432 是指786432bytes?即:768MB 98304 bytes=96MB 那0.75M是怎么算出來的。
正確答案:786432bytes=768KB=0.75MB 98304bytes=96KB=0.09MB ?
最小是位 <其次字節(byte)<KB<MB<GB<TB
一個字節 =8位
1KB=1024B(字節)
1MB=1024KB
1GB=1024MB
1TB=1024GB
千,1KB=2的10次方=1024B,
兆,1MB=2的20次方=1024*1024B=1024KB,
吉,1GB=2的30次方=1024*1024*1024B=1024MB,
太,1TB=2的40次方=1024*1024*1024*1024B=1024GB,
拍,1PB=2的50次方=1024*1024*1024*1024*1024B=1024TB,
艾,1EB=2的60次方=1024*1024*1024*1024*1024*1024B=1024PB,
澤,1ZB=2的70次方=1024*1024*1024*1024*1024*1024*1024B=1024EB,
堯,1YB=2的80次方=1024*1024*1024*1024*1024*1024*1024*1024B=1024ZB.
今天一個客戶的網站出現這樣的錯誤。程序是PHP的。經百度了一下。說明內存不足。中文件翻譯的意思是:內存不足(分配786432)(嘗試分配98304字節)
意思是嘗試分配98MB的內存。但一般php設置為只允許給php程序分配 0.75M內存
解決辦法:打開php.ini 修改memory_limit = 的這行
依照服務器配置進行調整
配置的內存使用大小修改后重啟iis/apache
問題解決^^
PHP5.2.3-win32這個版本有個非常嚴重的bug,那就是最大內存設置成1024M,但是PHP實際返回的只有2M,經常返回下面的錯誤:
PHP Fatal error: Out of memory (allocated 1048576) (tried to allocate 393216 bytes)
PHP Fatal error: Out of memory (allocated 1048576) (tried to allocate 393216 bytes)
PHP Fatal error: Out of memory (allocated 1048576) (tried to allocate 393216 bytes)
PHP Fatal error: Out of memory (allocated 1048576) (tried to allocate 393216 bytes)
PHP Fatal error: Out of memory (allocated 786432) (tried to allocate 393216 bytes)
PHP Fatal error: Out of memory (allocated 1310720) (tried to allocate 393216 bytes)
這是官方的bug報告,該bug只出現于windows版本,linux版本沒有這個bug。看來只能等下一次升級的時候修復了。PHP5.2.3-win32 我的是PHP5.2.8-win32 怎么還是會偶爾出現?