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.
Comments
Hennie (not verified)
February 29, 2012 - 04:49
Permalink
thanks!
You are my hero of the day! I had the same problem and your post sorted it out quickly.
Thanks a lot for taking the time to post this article.
Aftab (not verified)
March 4, 2012 - 06:46
Permalink
Thanks
Thank you very much. I have tried many things to resolver the issue but your article help me to understand the problem and resolve it. Thanks a lot again.
Kevin
March 9, 2012 - 15:26
Permalink
Glad to have helped!
You are both very welcome. I'm glad the article helped at least a few people out.
Gionie (not verified)
May 25, 2012 - 06:54
Permalink
Great Help!!!
Great Help!!!
Walter B. (not verified)
January 21, 2013 - 19:54
Permalink
A life-saver!
This was the ticket! As a Drupal nube, working on configuring my son's developer instance site, I probably overdid it with installing various modules and ran up against the exact problems and solutions which you described clearly in your post. I thought I was locked out of the site... But now I'm back in and working! Thanks a lot!
Shannon (not verified)
January 30, 2013 - 15:40
Permalink
THANK YOU!!!
Amazing, thank you for posting this! Worked like a charm! :)
Nina (not verified)
May 9, 2013 - 22:58
Permalink
thanks!
Let me add my thanks to the others. You just saved my life, or at least my site.
Jake (not verified)
June 6, 2013 - 16:32
Permalink
You saved the day!
Thank you so much for posting this. It worked a charm.
Superpomme (not verified)
July 10, 2013 - 07:33
Permalink
Cheers!
That was really useful - thanks for that info - worked a dream
Misha (not verified)
July 22, 2013 - 13:15
Permalink
THANKS!!!
You are a Lifesaver !!!
Jesus Verde (not verified)
February 5, 2014 - 02:22
Permalink
You save my life!!!
I was looking for this solution like for ever and almost give up. Great tip.
Nageshwari (not verified)
May 6, 2014 - 00:57
Permalink
In which directory need to
In which directory need to add php.inc?
Kevin
May 7, 2014 - 01:21
Permalink
php.ini location
It needs to be in your web root directory. This is where the index.php file should be.
shekoufeh (not verified)
April 19, 2015 - 23:53
Permalink
why it does not work for me!!
why it does not work for me!! :'(
Anonymous (not verified)
March 25, 2018 - 11:25
Permalink
The best thing what you must
The best thing what you must do is that before uploading any image or data into durpal. You better check your memory and then try to upload your stuff. Last time when I tried to upload my http://best-essay-writing-service.reviews/essayshark-com-review/ blog article into durpal I faced the same problem you have faced. I reduced the article size and uploaded.