Avatar ·

PHP 致命错误:内存限制 134217728 字节(128 MB)已耗尽

大家好!我是一名 PHP 初学者,在本地服务器(OpenServer)上执行脚本时,不断出现以下错误: ``` Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in D:\projects\parser\index.php on line 45 ``` 我有一个简单的新闻解析器,从另一个网站抓取标题和链接,使用的是 Simple HTML DOM Parser。脚本处理大约 5000 个页面。以下是我的代码示例: ```php find('h2.news-title a') as $link) { $title = $link->plaintext; $href = $link->href; echo "$title - $href\n"; } // 我以为我在清理内存 $html->clear(); unset($html); } echo "完成!"; ?> ``` 问题大约出现在第 200 次迭代时。我尝试在 php.ini 中增加 memory_limit,