Solve PHP Fatal error: Allowed memory size of 8388608 bytes exhausted (tried...

Home -> Programming -> Web -> PHP

129408 views

From the computer of: Rex (39 recipes)
Created: Nov 25, 2004


0 comments:
View all comments

Add a comment

Add to:
Add to stumbleuponAdd to del.icio.usDigg itAdd to FURL

This error message can spring up in a previously functional PHP script when the memory requirements exceed the default 8MB limit. Don't fret, though, because this is an easy problem to overcome.

To change the memory limit for one specific script by including a line such as this at the top of the script:

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


The 12M sets the limit to 12 megabytes (12582912 bytes). If this doesn't work, keep increasing the memory limit until your script fits or your server squeals for mercy.

You can also make this change permanently for all PHP scripts running on the server by adding a line like this to the server's php.ini file:

memory_limit = 12M


Keep in mind that a huge memory limit is a poor substitute for good coding. A poorly written script may inefficiently squander memory which can cause severe problems for frequently executed scripts. However, some applications are run infrequently and require lots of memory like importing and processing a big data file.

Subscribe to the Tech-Recipes Newsletter

You can get tips like this delivered in your email every week!

Enter your Email

We will never, ever sell your email address or spam you.





Related recipes:

  Solve PHP error: Cannot modify header information - headers already sent
  PHP: Upload Files to the server
  PHP: Delete or expire a browser cookie
  PHP syntax: for loop basics
  PHP if statement syntax
  PHP syntax: iterate over an array
  PHP: Read a browser cookie value
  PHP: determine the directory path of the server root
  PHP: Generate Dynamic Images from Text
  PHP syntax: variable assignments

 

Sponsored links

 

Login

Nickname

Password

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.