且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

致命错误:内存不足

更新时间:2022-06-27 00:08:45

您可以通过ini_set提高php的内存限制,但这只能基于每个脚本来完成(例如,从非常大的数据库中导入数据) xml/etc文件).解决提高内存限制的好问题-增加PHP memory_limit.在什么时候变得疯狂?.

You can raise php's memory limit, via ini_set, but this should only be done on a per-script bases (eg, importing data from a very large xml/etc file). Excellent question that addresses raising memory limit - Increasing PHP memory_limit. At what point does it become insane? .

阅读更新文章,以您为例,我提高了内存限制-假设您编写了一次使用快速脚本.如果ini_set被禁用(即,很可能是您在共享主机上),请在php.ini中设置memory_limit.

Read update post, in your case I'd raise the memory limit - assuming your writing a quick script for one time use. If ini_set is disabled (ie, most likely if your on a shared host), set memory_limit in php.ini.

另一种选择是使用套接字来获取页面(读取数据成小块,然后保存到文件或w/e)或运行系统命令(例如,wget -O /save/here.txt http://blah.com)

Another option would be to use sockets to fetch the page (read data in small chunks, and save to file or w/e) or run a system command (eg, wget -O /save/here.txt http://blah.com)