When working in WordPress or other PHP applications, it’s relatively common to run into memory limit errors like the following:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 122880 bytes) in /public_html/wp-admin/includes/template.php on line 699
The default memory limit setting is in the php.ini file, and many web hosts have it set to 12MB. You can change it by modifying the php.ini file:
[code]memory_limit = 64M[/code]
…but, many hosts don’t give you direct access to this file.
Instead, you can control the memory limit directly in your application. In the wp-config.php file, just add a single line:
[code language=”php”]define(‘WP_MEMORY_LIMIT’, ’64M’);[/code]
This issue came up on a recent project involving the BuddyPress WordPress plugin, which can be a fairly memory intensive module. If you run into it, just bump up your memory limit and you should be fine. If you’re using a platform other than WordPress, there are usually similar methods to define memory limits – just check the documentation for your particular application.