2016年5月18日

(SimplePie) Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 311296 bytes)

今天使用 SimplePie php library 一直發生這個問題.
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 311296 bytes)

很多文章都是指出是 PHP memory 給得不夠.. 比如要在 php.ini 設定,但我們一直調高這個值,無法解決我們的問題。
memory_limit = 32M

但我們的情形是設定的 cache 目錄包含的檔案太多 (too many files on cache directory)
$feed = new SimplePie();
$feed->set_feed_url(TARGET_URL);
$feed->set_cache_location(CACHEDIR_SIMPLEPIE);

只要一個獨立的 CACHEDIR_SIMPLEPIE 目錄給 SimplePie,就我們的情形,這樣才能解決。初步判斷,SimplePie 會去 scan files on CACHEDIR_SIMPLEPIE (Why? We have no idea)。

 

 

Orignal From: (SimplePie) Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 311296 bytes)