Jeremy Roy
Jeremy Roy

Reputation: 1291

Out of memory and Internal Server Error while trying big scripts

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

I am having this problem I noticed. I am getting the out of memory related 500 internet server error while trying to write big scripts. Big in the sense that I do a query that gives 4000 or 5000 rows, and I try writing them all using a foreach (for an excel extraction in this given case).

The php is giving exactly in the line that serves the foreach statement.

Anyone experienced to show me some light on this one please?

Upvotes: 0

Views: 2576

Answers (2)

0xAli
0xAli

Reputation: 1059

PHP Fix:

ini_set('memory_limit', '64M');

.htaccess Fix:

php_value memory_limit 64M

php.ini Fix:

memory_limit = 64M

Upvotes: 1

Fosco
Fosco

Reputation: 38526

Edit your php.ini file and increase the memory_limit.

Or, at the top of this script, include:

ini_set("memory_limit","256M");

Upvotes: 3

Related Questions