Philadelphia Reflections

The musings of a physician who has served the community for over six decades

Related Topics

No topics are associated with this blog

PHP out of memory condition

Fatal error: Allowed memory size of 18388608 bytes exhausted 
(tried to allocate 724 bytes) in /home/dir1/dir2/script.php on line ###

When working with large amounts of data in memory (very long concatenated strings and/or very large arrays in my case), the server may hit a memory max. No amount of "unset" of variables will do the trick past a certain point.

This is the result of a memory allocation ceiling set in php.ini that can be over-ridden (judiciously) as follows:

ini_set  ("memory_limit", -1  );

Be sure to test your code with smaller amounts of data first: this limit is set for a reason ... programs have been known to have been poorly written (not yours, of course; but test anyway).

Originally published: Tuesday, June 17, 2008; most-recently modified: Monday, June 04, 2012