Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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 ......

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

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

like image 744
Mathlight Avatar asked Jun 19 '13 09:06

Mathlight


People also ask

What does memory_limit =- 1 mean?

memory_limit = -1. Simply means to "have no memory limit" meaning: let the script use whatever is left over from the operating system and other important processes running.

How do I fix out of memory error in PHP?

Create a phpinfo. php file under root directory and check for current memory limits. By default memory limit is 8M, but in this case you have to increase the memory limits to 12M, 16M, 24M and so on with this line. This will increase your memory limit and solve this error.

What is the maximum PHP memory limit?

Increasing the PHP memory limit The default memory limit is 256M and this is usually more than sufficient for most needs. If you need to raise this limit, you must create a phprc file.


1 Answers

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

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

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

like image 186
Michal M. Avatar answered Sep 28 '22 00:09

Michal M.