2013-04-15 73 views
-1

我有一個Drupal論壇網站,它有大量的數據。例如,一個論壇類別有14,000個線程,並有100,000條評論。即使在我的本地測試網站,它也非常滯後。然後當我上傳到活動網站,它給這個錯誤:如何限制Drupal查詢中的內存分配?

Fatal error: Allowed memory size of 52428800 bytes exhausted (tried to allocate 40961 bytes) in /home/fmotors/public_html/development/includes/theme.inc on line 1494 

所以有事情做與增加的內存限制,或者一次不查詢所有線程。但我不知道如何去做。下面是該標記上述錯誤代碼:

function theme_render_template($template_file, $variables) { 
    extract($variables, EXTR_SKIP);    // Extract the variables to a local namespace 
    ob_start();         // Start output buffering 
    include DRUPAL_ROOT . '/' . $template_file; // Include the template file 
    return ob_get_clean();      // End buffering and return its contents 
} 

ob_start()呼叫處於線1494。順便說一句,我使用的Drupal的提前論壇模塊。

+0

返回更少的數據。沒有看到您的查詢,很難提供詳細信息。 –

+0

如果Drupal和Wordpress一樣,它可能會試圖在內存中保存所有註釋,即使您使用的視圖是分頁的。如果這是問題,那麼搜索「drupal php減少內存使用量」將是一個不錯的第一步。也就是說,對於一個複雜的PHP應用程序,50M可能太少了:嘗試配置64或80M並查看它是否有效? – halfer

+0

@halfer在哪裏配置50M到80M?以及我如何不一次查詢所有評論?是的,他們分頁,我懷疑你說什麼是真實的,即使它分頁,一次全部查詢。 –

回答

0
在configuraion或索引文件

設置

ini_set('memory_limit', 0); 
+0

這只是爲了解決問題而不是解決問題嗎?現在還有另一個潛在的錯誤,腳本可能會佔用太多的系統內存,導致更難追蹤錯誤。 – siride