PHP:使用 php.ini 或 init_set 分配内存
运行脚本时,我不断收到以下消息:
Out of memory (allocated 58458112) (tried to allocate 20 bytes)
当我更改 php.ini 中的 memory_limit 或将 ini_set("memory_limit","1024M")
放在脚本顶部时,消息为完全相同,就好像没有使用额外的内存来运行脚本一样。我还可以做些什么来分配更多内存(除了优化脚本之外......它是 Magento,需要彻底检修,但它没有专业知识来修复它)。
I keep getting the following message when running a script:
Out of memory (allocated 58458112) (tried to allocate 20 bytes)
When I change the memory_limit in the php.ini or put ini_set("memory_limit","1024M")
at the top of the script, the message is the exact same, as though no additional memory was used to run the script. Is there something else I can do to allocate more memory (outside of optimizing the script... it's Magento, which needs an overhaul, but it don't have the expertise to fix it).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Magento 是一个真正的内存消耗大户,我们必须升级服务器才能运行它。
尝试将顶级 .htaccess 文件中的内存限制设置为类似这样的内容(这对我们有用)
php_value memory_limit 256M
(如果您在共享服务器上,这可能也没有效果,但值得一试。)
Magento is a real memory hog, we've had to upgrade the server to run it.
Try setting the memory limit in the top level .htaccess file to something like this (which is working for us)
php_value memory_limit 256M
(If you're on a shared server this may have no effect either but it's worth a try.)
这可能是由于您的 ulimit 设置造成的。运行 ulimit -a ,您可能会发现大约 58MB 标记,我猜是 64000。您可以使用 ulimit 命令更改它,但可能需要编辑/etc/security/limits.conf 以使其持续存在。
This is probably due to your ulimit settings. Run
ulimit -a
and you will probably find something around that 58MB mark, i'm guessing 64000. You can change it with theulimit
command, but will probably need to edit /etc/security/limits.conf to make it persist.