Fatal error: Allowed memory size exhausted


Drupal can be very memory intensive CMS, especially if you have lots of menus, blocks and modules. If you exhaust the allowed memory size, you would get an error such as the following

Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 41 bytes) in somefile

To fix this problem, you need to allocate more memory.

1. Open you php.ini file If you don’t know where this file is, run locate php.ini. Mine is located at /etc/php.ini. Make sure you back up this file before editing it.

1. Open you php.ini file If you don’t know where this file is, run locate php.ini. Mine is located at /etc/php.ini. Make sure you back up this file before editing it.

2. set memory_limit to 32M Find memory_limit and modify 16M to 32M. You can choose more if you think you would need more memory.

3. restart apache /sbin/service httpd restart

4. insert a line in settings.php Edit sites/default/settings.php inside your drupal directory. Insert the following line.

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

If this doesn’t work try using 64M or more. If you program is taking too much memory, you should check to see if it is coded properly.