出现这个错误消息,有什么建议吗?

允许内存大小为33554432字节已耗尽(已尝试分配 43148176字节)的PHP


当前回答

我没有更新主机,数据库是只读的。Joomla需要编写会话,但无法完成。

其他回答

It is unfortunately easy to program in PHP in a way that consumes memory faster than you realise. Copying strings, arrays and objects instead of using references will do it, though PHP 5 is supposed to do this more automatically than in PHP 4. But dealing with your data set in entirety over several steps is also wasteful compared to processing the smallest logical unit at a time. The classic example is working with large resultsets from a database: most programmers fetch the entire resultset into an array and then loop over it one or more times with foreach(). It is much more memory efficient to use a while() loop to fetch and process one row at a time. The same thing applies to processing a file.

在Wordpress中切换到一个新主题后,我收到了同样的错误信息。PHP运行的是5.3版本,所以我切换到了7.2。这解决了问题。

这里有两个简单的方法来增加共享主机的限制:

如果您可以访问PHP.ini文件,请更改PHP.ini中的行 如果你的线显示为32M,试试64M: memory_limit = 64M;一个脚本可能消耗的最大内存(64MB) 如果你不能访问PHP.ini,试着把这个添加到。htaccess文件中: php_value memory_limit 64M

你可以通过执行下面的代码来增加php脚本的内存:

ini_set('memory_limit','-1'); // enabled the full memory available.

并且在脚本中取消分配不需要的变量。

ini_set (memory_limit’,‘- 1);

在你的index.php中,在PHP标签打开后的顶部