php - PHP memory_limit 越多越好吗?

标签 php performance memory memory-limit

在 PHP 中,我经常遇到内存限制问题。尤其是像 Drupal 等高度资源集成的系统。

这里我想知道的是:

  • 2GB这样的高php内存限制是不是很好?
  • 有什么大的缺点吗?

已编辑:

As a scenario, for example in Drupal, it NEEDS so much memory while we CLEAR the CACHE via Web Panel (Not by Drush or any script). So even for this case only, i am definitely needing high-limit around 512MB currently.

最佳答案

黄金法则:只为 PHP 提供 PHP 需要工作的部分,仅此而已。

这将防止您的系统不必要地阻塞 PHP 进程的情况,并且还将帮助您发现错误(占用 1GB 内存的脚本是不寻常的,并且提供 2GB 内存限制将隐藏这一点)。


对于特殊情况,如果您知道单个脚本文件非常占用内存,您可以使用 ini_set()在运行时更改内存限制指令。见 this this

关于php - PHP memory_limit 越多越好吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12858457/

相关文章:

javascript - 如何使用 AJAX 删除 PHP $_SESSION?

php - 为什么我在 PHP 中收到 SSL 错误,即使我启用了 php_openssl.ext?

performance - 从 1 x n 向量创建一个 n x n-1 矩阵,其中第 i 行是没有第 i 个元素的向量,没有 for 循环

C语言: pointer returned by malloc() and casting

c++ - shared_ptr-如何忽略第一个引用?

javascript - 如何通过AJAX查看数据库字段

algorithm - 寻找素数的快速算法?

c++ - 您能否在任何独立于体系结构的低级语言中获得更小的整数?

c++ - 谁能解释常量或 const 变量存储在哪里?

php - 获取分组依据的查询结果