久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

致命錯誤:內(nèi)存不足,但我確實有足夠的內(nèi)存 (P

Fatal error: Out of memory, but I do have plenty of memory (PHP)(致命錯誤:內(nèi)存不足,但我確實有足夠的內(nèi)存 (PHP))
本文介紹了致命錯誤:內(nèi)存不足,但我確實有足夠的內(nèi)存 (PHP)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

由于我的問題越來越長,我決定重新編寫整個問題以使其更好更短.

Since my question is getting longer and longer, I decide to re-write the whole question to make it better and shorter.

我在具有 8GB 內(nèi)存的專用服務(wù)器上運行我的網(wǎng)站.我完全知道我需要提高 php.ini 設(shè)置的內(nèi)存限制.我已將其從 128M 設(shè)置為 256M 并設(shè)置為 -1.問題仍然是持久性.

I run my website on dedicated server with 8GB memory. I am fully aware that I need to raise the memory limit on php.ini setting. I have set it from 128M to 256M and to -1. Still the problem is persistence.

致命錯誤:內(nèi)存不足(已分配 786432)(嘗試分配 24576字節(jié))在 D:wwwfootballviewsmain.php 中的第 81 行

Fatal error: Out of memory (allocated 786432) (tried to allocate 24576 bytes) in D:wwwfootballviewsmain.php on line 81

內(nèi)存不足是沒有意義的,因為它說只分配了 786432 個字節(jié),而它需要更多的 24576 個字節(jié).

The out of memory does not make sense because it said only 786432 bytes is allocated and it needed 24576 bytes more.

786432 字節(jié)僅為 768 KB,相當小.

786432 bytes is only 768 kilobytes and is fairly small.

  • 錯誤發(fā)生在非常隨機的行上.它并不總是在第 81 行出錯.
  • 在高峰時間,Apache 只占用大約 500MB 的內(nèi)存.我還有 6GB 可用空間.
  • 沒有無限循環(huán).
  • 腳本占用 1,042,424 個字節(jié).從 echo memory_get_peak_usage();
  • 獲取這個數(shù)字
  • 來自 MySQL 的結(jié)果集很小(最多 12 行,純文本,沒有 blob 數(shù)據(jù))
  • (重要)如果我每兩天重啟一次 Apache,錯誤就會消失.這通常發(fā)生在 Apache 運行超過 2 天時.
  • 我已經(jīng)包含了腳本的分析,您可以在此處獲取它.
  • 此專用服務(wù)器僅用于運行一個網(wǎng)站.該網(wǎng)站是一個高流量網(wǎng)站,平均每分鐘有 1,000 名訪問者.在高峰時段,將有 1,700 至 2,000 名訪客同時訪問.
  • The error occurs on a very random line. It does not always error on line number 81.
  • At peak time, Apache only takes around 500mb of memory. I still have 6GB to spare.
  • There is no infinite loop.
  • The script takes 1,042,424 bytes. Getting this number from echo memory_get_peak_usage();
  • The resultset from MySQL is small (at most 12 of rows, purely text, no blob data)
  • (Important) If I restart Apache once every two days, the error is gone. It usually happens when Apache is running more than 2 days.
  • I have included the profiling the script and you can get it here.
  • This dedicated server is purely used to run only one website. This website is a high traffic website with average of 1,000 visitors every minute. At peak time, there will be 1,700 to 2,000 visitors accessing at the same time.

操作系統(tǒng):Windows 2008 R2 64 位
CPU:英特爾酷睿 i5 - 4 核
內(nèi)存:8 GB
Apache 2.2
PHP 5.3.1
存儲:2 x 1 TB 硬盤
帶寬:每月 10 TB

OS: Windows 2008 R2 64-Bit
CPU: Intel Core i5 - 4 cores
RAM: 8 GB
Apache 2.2
PHP 5.3.1
Storage: 2 x 1 TB hard drives
Bandwidth: 10 TB per month

解決方案

我終于調(diào)整并解決了問題,我想在這里分享我所做的改進:

Solution

I have finally tuned up and fixed the problem and I would like to share it here what I have done to improve:

  1. favicon.ico 丟失了,這會影響我的路由引擎.雖然我的路由引擎非常小,但是通過包含 favicon.ico,它可以通過不運行我的路由引擎來幫助減少內(nèi)存使用.我網(wǎng)站的大部分內(nèi)容都有它,但我忘了把它放在這個新部分.
  2. Limit MaxRequestPerChild 有幫助.在我的另一個專用服務(wù)器中,我的 MaxRequestPerChild 受到限制.對于這個服務(wù)器,我設(shè)置為0.我一直認為每個腳本都是隔離的.假設(shè)我的腳本需要 800kb 才能運行.完成后,Apache 或 PHP 應該釋放 800kb 內(nèi)存.似乎它不能以這種方式工作.受限 MaxRequestPerChild 確實有助于通過在受限 MaxRequestPerChild 和舊進程即將死亡后創(chuàng)建新進程來防止內(nèi)存泄漏.這是我的新設(shè)置.

  1. favicon.ico was missing which mess up with my route engine. Although my route engine is very small, but by including favicon.ico, it helps reduce memory usage by not running my route engine. Most of part of my website has it and I forgot to put it for this new section.
  2. Limit MaxRequestPerChild helps. In my other dedicated server, I have my MaxRequestPerChild limited. For this server, I set it to 0. I always thought that each script is isolated. Lets say if my script takes 800kb to run. Upon its completion, Apache or PHP should free 800kb memory. It seem like it doesn't work this way. Limited MaxRequestPerChild does help to prevent memory leak by creating new process after limited MaxRequestPerChild and the old process is dying. This is my new setting.

ThreadsPerChild      1500
MaxRequestsPerChild  10000 

  • ob_flush(); 確實減少了更多的內(nèi)存.它沒有多大幫助,但每一點優(yōu)化都有幫助.

  • ob_flush(); does reduce slightly more memory. It does not help much but every bit of optimization helps.

    推薦答案

    我遇到了同樣的問題,在嘗試使用交換時服務(wù)器死機.這是因為mod_php 永遠不會釋放內(nèi)存.因此 Apache 進程不斷增長,要么達到 apache 或 PHP 的內(nèi)存限制,要么在沒有限制的情況下使服務(wù)器崩潰.

    I ran accross the same kind of problem with the server dying when trying to use the swap. This is because mod_php does not free memory ever. So Apache processes keep growing either reaching apache or PHP's memory limit or, if there's no limit, crashing the server.

    重新啟動 apache 使其產(chǎn)生新的新的細長進程,但是隨著它們運行 PHP 腳本,它們會隨著時間的推移而增長,直到出現(xiàn)問題.

    Restarting apache makes it to spawn new fresh slim processes but as they run PHP scripts over time, they grow until problems arise.

    解決方案是讓apache在提供一定數(shù)量的查詢后殺死進程,以便創(chuàng)建新的進程(有與此相關(guān)的一些問題) 減少MaxRequestsPerChild 配置選項,假設(shè)為 100(默認為 1000).

    The solution is to make apache to kill processes after a certain number of queries served so it will create new ones ( There are some questions related to that) reducing the MaxRequestsPerChild configuration option to, let's say 100 (Defaults to 1000).

    當然,這可能會降低服務(wù)器性能,因為它需要資源來終止和生成新進程,但至少它可以保持站點正常工作.您可能想增加正在運行的進程數(shù)以保持高性能,確保 PHP(或 apache)內(nèi)存限制 x 最大進程數(shù)不會超過服務(wù)器的物理內(nèi)存.

    Of course this may reduce server performances as it takes ressources to kill and spawn new processes but at least it keeps the site working. You might be tempted to raise the number of running processes to keep performances high, be sure PHP (or apache) memory limit x max number of processes do not get over your server's physical ram.

    以下是我的經(jīng)驗,希望對您有所幫助.

    Here's my experience, hope it helps.

    這篇關(guān)于致命錯誤:內(nèi)存不足,但我確實有足夠的內(nèi)存 (PHP)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

    【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!
  • 相關(guān)文檔推薦

    Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
    How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設(shè)置?)
    Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動填充選擇框)
    PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
    json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產(chǎn)生 JSON_ERROR_UTF8)
    MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
    主站蜘蛛池模板: 欧美视频二区 | 久久久久亚洲 | av一区二区三区四区 | 亚洲精品欧美一区二区三区 | 亚洲精品一区二三区不卡 | 97超碰中文网 | 国产一区久久精品 | 91欧美精品成人综合在线观看 | 天天色天天 | 97碰碰碰 | 免费看淫片 | 在线亚洲电影 | 二区三区av | 91一区二区| 欧美黑人国产人伦爽爽爽 | 久久国产日韩欧美 | 亚洲成人免费视频在线 | 亚洲欧美国产一区二区三区 | 99精品视频在线 | 91在线观看| 欧美一区二区大片 | 亚洲国产精品网站 | 免费av观看| 欧美一区二| 天天摸天天干 | 一区二区三区四区在线视频 | 免费黄色片视频 | 国产精品一区二区久久 | 伊人99| 成人免费精品 | 先锋资源吧 | 日韩中文字幕网 | 亚洲视频在线播放 | 99reav| 亚洲精品一区二区三区在线 | 国色天香综合网 | 欧美日韩免费一区二区三区 | www.国产.com | 国产乱肥老妇国产一区二 | 成人精品一区二区三区 | 亚洲精品在线免费 |