Fix Drupal “Fatal error: Allowed memory size of…” error.

This error can occur for multiple reasons. In my case, it occured when trying to edit an already existing drupal page. I would attempt to edit the page, and Drupal would respond with this:

Fatal error: Allowed memory size of 18874368 bytes exhausted (tried to allocate 1481725 bytes) in __/public_html/includes/ on line 224

Fix 1:

What we need to do is increase the allowed memory size for php scripts. This is easy assuming that you know the location of your php.ini file (if you don’t, read Fix 2).

Inside this file, find the following line and make the following changes:

memory_limit = xxM; (xx – your current value)


memory_limit = 50M;

Note: You might have to increase the number depending on how many modules your Drupal installation is using.

Fix 2:

If you cannot find your php.ini file, either it does not exist yet, or your host won’t allow you to access it. We will assume that the file does not exist yet, so lets create it.

Save the following code into a file named php.ini:

memory_limit = 40M;

upload_max_filesize = 20M;

post_max_size 20M;

max_execution_time = 200;

max_input_time = 200;

Put this file in your Drupal website root folder, …/public_html/.

Your memory error should no longer occur after this fix, however considering there are many reasons for this error to occur it might also not work.