While uploading some pictures of my new laptop I ran into a problem with the Drupal Image module running out of memory when it tried to create the different image styles of my uploaded photos.
The message I was getting was similar to the following although at the time I neglected to record the whole thing.
PHP Fatal error: Out of memory (allocated 34078720) (tried to allocate some amount of bytes) in some file on line some number
This is a pretty standard out of memory error so I contacted my web host, Canadian Web Hosting, and asked them if they could increase the memory limit. They complied as it seems my account is actually allowed a memory limit of 64M and added a custom
php.ini in my
public_html directory with the following in it:
memory_limit = 64M
This should have done the trick but for some reason it led to another fatal error message:
Fatal error: Class 'PDO' not found in /some directory/public_html/includes/database/database.inc on line 184
It seems the custom
php.ini file was overriding whatever existing file had been loading the PDO class. After consulting Google I found the following information at php.net.
The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.
PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn't rewrite SQL or emulate missing features. You should use a full-blown abstraction layer if you need that facility.
PDO ships with PHP 5.1, and is available as a PECL extension for PHP 5.0; PDO requires the new OO features in the core of PHP 5, and so will not run with earlier versions of PHP.
Basically PDO is an extension that allows PHP to talk to the MySQL database which stores the data of my Drupal site. The following additional lines to the custom
php.ini fixed the problem by initializing the extension and the MySQL specific PDO driver.
extension = pdo.so
extension = pdo_mysql.so
This did the trick and as you can see the site is up and running again. Hopefully this will save someone else the time spent diagnosing this problem.