[Plugin: NextGEN Gallery] Exceed Memory Limit - I've Done Everything (21 posts)

  1. mbeazley
    Posted 8 years ago #

    I'm running NextGen-Gallery (.96) on WordPress MU 1.5.1 (WP 2.5.1 core). My relevant php.ini settings are as follows:
    upload_max_filesize = 50M
    memory_limit = 64M
    post_max_size = 50M

    When I attempt to upload an image that is 169KB the image uploads and the thumbnail is created as expected.
    When I attempt to upload an image that is 1.32MB I get the following error : "img_3877.jpg (Error : Exceed Memory limit. Require : 35.38 MByte)" & no thumbnail is created.

    When I attempt to 'create new thumbnails' within the Gallery itself I get the same error.

    I also ran the 1&1 memory script and passed all the tests.

    What the heck? How in the world is 35.38 MBytes needed to create a thumbnail for a 1.32MB image? And even if it does, what setting is not right in my php.ini file?

    I've read every related post I can find. Can't see what I'm missing. I'm stumped.

  2. Joni
    Posted 8 years ago #

    Did you ask your web host to up your php memory limit to something like 48MB? Sometimes just futzing with the .htaccess or php.ini file doesn't do the trick.

  3. Alex Rabe
    Posted 8 years ago #

    What the heck? How in the world is 35.38 MBytes needed to create a thumbnail for a 1.32MB image?


  4. mbeazley
    Posted 8 years ago #

    Thanks for the help. I understand the memory limit issue related to thumbnails now thanks to the link. Thanks, Alex! Unfortunately I'm still having the same issue. My web host has confirmed that php.ini sets my memory limit. It is set to 64MB as noted in my original post. They don't otherwise restrict the memory limit.

    It is curious to me that when I attempt to upload an image via: 'Gallery > Add Gallery > Upload Images' there is a note under the 'Choose Gallery' pull-down menu that says 'Note : The upload limit on your server is 2MByte '.

    Also after attempting to upload an image of 1.32 MB (2272x1704) the image uploads successfully, but the thumbnail fails to create and gives the following error: img_3877.jpg (Error : Exceed Memory limit. Require : 35.2 MByte).

    I'm also wondering if the php.ini script needs to be in a directory other than my web root?

    Any more help would be much appreciated.

  5. Joni
    Posted 8 years ago #

    From what I understand, the php.ini fine is not recursive; it needs to be in each directory where the problematic script resides.

    I know for my case, with Alex's (wonderful!!!!) Next Gen Gallery, I was having problems with thumbnail creation until I asked my web host to up my memory limits. :)

  6. mbeazley
    Posted 8 years ago #

    Joni, thanks for the input. My web host insists that they do not control my memory limits. The only way to lower or raise the limit is via the php.ini which I have complete control over.

    As far as placement of the php.ini file, sounds like you literally copied it to every directory associated with Nextgen-Gallery. I wonder about a better approach. Someone suggested you could create a symbolic link to the file via .htaccess. This would allow an easy undo of this change if necessary. It would also take care of added directories in the future. I'm not very good at modifying the .htaccess file. If someone knows how to do what I'm talking about I'd appreciate any help.

  7. Alex Rabe
    Posted 8 years ago #

    Does NGG shows under server settings a memory limit of 32 MB or 64 MB ?

  8. mbeazley
    Posted 8 years ago #

    Alex, where do I find the 'server settings' you mention?

  9. Alex Rabe
    Posted 8 years ago #

    Ok I see you have WPMU (there it's hidden), so you need read the memory_limit with phpinfo()

  10. mbeazley
    Posted 8 years ago #

    This gets interesting. phpinfo() returns different results depending on which directory it is in:

    * if my updated php.ini is in the same directory as phpinfo.php then phpinfo.php returns the modified settings (memory_limit=64MB & upload_max_filesize=50MB)

    * if my updated php.ini is NOT in the same directory as phpinfo.php then phpinfo.php returns the default settings (memory_limit=32MB & upload_max_filesize=2MB)

    The question is - Where does php.ini need to be located for NGG to work with the modified settings?

  11. mbeazley
    Posted 8 years ago #

    Well, I took a bit of a brute force approach. I copied the php.ini file to the root directory for my WP install and to every sub-directory under it. That fixed the issue.

    I hope it doesn't cause me trouble in the future. For others who need to take a similar approach I used this script to do the work of copying the php.ini to all the sub-directories:

    system("find * -type d|xargs -i cp --verbose php.ini {}/.");

    Here's what you do:

    1. Create a new file called 'copyphpini.php' in your WP root.
    2. Paste the code above in the file & save.
    3. Use a web browser to go to: http://www.yourdomain.com/wpdirectory/copyphpini.php
    4. The locations to which the file is copied will output in the browser window

    I cannot guarantee that the additional instances of your php.ini file will not muck up things for you. Undoing could be as easy as modifying the script to remove instead of copy, but I haven't tried.

  12. likoma
    Posted 8 years ago #

    After much trial and error (mostly error), I think I figured out that the file goes into the /wp-admin/ folder. More explanation here.

  13. staceppa
    Posted 8 years ago #

    i am in the same situation, i have really done everything but i still get the same error.
    in order i have:
    - edited an .htaccess file
    - edited a php.ini file
    - ran into the test here http://alexrabe.boelinger.com/2008/03/21/11-3/ (you can see the results here http://www.noiduepercaso.com/test/test.php which says that it works)

    every single time i try to upload a picture, no matter how little it is i get:
    Error : Exceed Memory limit. Require : 42.78 MByte)

    what can i do?
    the information on nextgen-gallery says
    Memory usage : 40.91 MByte
    # PHP Max Upload Size : 32M
    # PHP Max Post Size : 32M

    i have also disabled all the plugins that i did not need!
    any help is much appreciated!


  14. staceppa
    Posted 8 years ago #

    ok, after searching and searching i solved it!
    just add this line
    `ini_set("memory_limit", "48M");

    at the top of

    it just works!

  15. fransalmere
    Posted 8 years ago #

    Is it me

    or can't this be right `ini_set("memory_limit", "48M");

    'this given unexpected error

    What should this be. I still have the problem

  16. pindsvin
    Posted 8 years ago #

    It's even easier. Find this document:

    search for
    // @ini_set('memory_limit', '128M');

    change it to
    ini_set('memory_limit', '128M');

    save. upload. ready!

  17. Minkus
    Posted 7 years ago #

    This tripped me up for a few hours - if you upload a large image and get the memory limit error, you have to go in manually (SSH, FTP, etc.) and delete that image. Otherwise you will never be able to upload to that gallery again, even if you delete it and recreate it. The large image will just stay there and give you memory errors ad infinitum.

  18. saeidzebardast
    Posted 7 years ago #

    Thanks pindsvin

  19. ggriffin
    Posted 7 years ago #

    I was STILL having trouble with 64M. I got further modifying thumbnail.inc.php, uncommenting:

    // @ini_set('memory_limit', '128M');

    as described here by pindsvin. It no longer shows an out of memory error, but it shows a blank page after it processes the thumbnails. I now see the thumbnails getting produced on the server under the wp-content/gallery/[gallery name]/thumbs directory, BUT NextGEN reports only ONE image in the gallery.

  20. AlanEdge
    Posted 7 years ago #


    If you are still having the memory issues, you may want to try an alternative:
    http://www.youtube.com/watch?v=9h3a1XXROKk (Demo)
    http://wordpress.org/extend/plugins/picturesurf-gallery/ (Download)

    Disclosure: I'm one of the people who worked on this plugin.

    Let me know if you run into similar memory issues again.

    Hope this helps.

  21. itsmrchris
    Posted 7 years ago #

    I continue to have problems creating thumbnails for "some" of my larger landscape photos.

    I have increased my memory to 500MB throughout, and the change is visible in my overview page. I am running PHP5. Also visible in the overview. I have run the memory test.php and passed. Also, I have un-commented line #168 re: 'memory_limit' to 500.

    The error I repeatedly receive is
    Fatal error: Out of memory (allocated 41156608) (tried to allocate 11264 bytes) in /home/asdff/public_html/asdfasdf/wp-content/plugins/nextgen-gallery/lib/gd.thumbnail.inc.php on line 183

    line 183 is:
    $this->oldImage = ImageCreateFromJpeg($this->fileName);

    Here are my settings:
    Operating System : Linux
    Server : Apache/2.2.10 (Unix) mod_ssl/2.2.10 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/
    Memory usage : 11.25 MByte
    MYSQL Version : 5.0.67-community
    SQL Mode : Not set
    PHP Version : 5.2.8
    PHP Safe Mode : Off
    PHP Allow URL fopen : On
    PHP Memory Limit : 500M
    PHP Max Upload Size : 500M
    PHP Max Post Size : 500M
    PHP Max Script Execute Time : 30s
    PHP Exif support : Yes ( V1.4 )
    PHP IPTC support : Yes
    PHP XML support : Yes

    GD Version : bundled (2.0.34 compatible)
    FreeType Support : Yes
    FreeType Linkage : with freetype
    T1Lib Support : No
    GIF Read Support : Yes
    GIF Create Support : Yes
    JPG Support : Yes
    PNG Support : Yes
    WBMP Support : Yes
    XPM Support : Yes
    XBM Support : Yes
    JIS-mapped Japanese Font Support : No

    ANY IDEAS? I am stuck.

Topic Closed

This topic has been closed to new replies.

About this Topic