php 使用 ini_set("memory_limit", "-1") 仍然内存不足

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17187126/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 12:26:51  来源:igfitidea点击:

Using ini_set("memory_limit", "-1") and still out of memory

phpapachememorylimiteasyphp

提问by Mathlight

I'm processing an old database php array to a new database. The data .php files are in total around 220 MB large.

我正在处理一个旧的数据库 php 数组到一个新的数据库。数据 .php 文件总共大约 220 MB 大。

I've inserted these lines in the script so that it should run fine:

我已经在脚本中插入了这些行,以便它可以正常运行:

ini_set("memory_limit", "-1");
set_time_limit(0);

This is how I include the products:

这就是我包含产品的方式:

// The exports made by PHPMYADMIN, exported as PHP-Array
require_once 'export/tx_ttproductsv2_products.php';
require_once 'export/tx_ttproductsv2_keyword.php';
require_once 'export/tx_ttproductsv2_keywords_in_products.php';
require_once 'export/tx_ttproductsv2_typebook.php';
require_once 'export/tx_ttproductsv2_typegospel7.php';
require_once 'export/tx_ttproductsv2_typemedia.php';

When the script is trying to require them I get this error:

当脚本试图要求它们时,我收到此错误:

PHP Fatal error: Out of memory (allocated 880541696) (tried to allocate 469762048 bytes) in ......

PHP 致命错误:内存不足(已分配 880541696)(试图分配 469762048 字节)......

I've got an local EasyPHP installation running on x64 Win 7 SP1. I've got 6 GB memory, Intel i5.

我有一个在 x64 Win 7 SP1 上运行的本地 EasyPHP 安装。我有 6 GB 内存,Intel i5。

How can I get PHP to run the whole script without the memory error?

如何让 PHP 在没有内存错误的情况下运行整个脚本?

采纳答案by M.M.

Memory limitation comes from the OS, not from PHP itself.

内存限制来自操作系统,而不是 PHP 本身。

Your script allocated 800MB and is trying to allocate further 500MB

您的脚本分配了 800MB 并试图进一步分配 500MB

Try to run the script on 64bit OS with 64 bit PHP.

尝试使用 64 位 PHP 在 64 位操作系统上运行该脚本。