致命错误:内存不足 [英] Fatal error: Out of memory

查看:195
本文介绍了致命错误:内存不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:

致命错误:内存不足(已分配123469824)(尝试分配71 个字节) /home/test/tset/tset.net/public_html/test/simple_html_dom.php在线 1236

Fatal error: Out of memory (allocated 123469824) (tried to allocate 71 bytes) in /home/test/tset/tset.net/public_html/test/simple_html_dom.php on line 1236

是的,我知道其中许多问题都是如此.但是我没有意识到避免这个错误有多么容易.如果出现此错误,我需要从下一个值开始循环.

Yes, I know that many of these issues were. But I did not realize how easy it is to avoid this mistake. I need if this error occurs, simply start the loop from the next value.

我使用 simplehtmldom

代码:

$html = file_get_html('http://www.windowsaffinity.com/?p=14721');

* 最大内存大小不足 *

推荐答案

您可以通过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)

这篇关于致命错误:内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆