What's behind tera byte ?

We reached already the PETA bytes. I heard some time ago that Ebay is already calculating their hard disc space in peta byte ( which is 1 000 000 000 000 000 byte ), but the memory limit of a PHP environment is sometimes only 8 Mbyte.

Is this a problem ?

The last days I get more feedback from users that they get a fatal error when they activate NextGEN Gallery or a blank screen when uploading some pictures (which is a fault on my side , that I didn’t do a correct error check). Now lets have a look at nextgen.boelinger.com

A simple WordPress installation and only 1 plugin activated :


And now have a look on alexrabe.de  (WordPress plus 22 plugins )


I also calculate the required memory for a 800 x 600 sized jpg, when you want to create a thumbnail : It up to 2,2 MByte in my internal tests… Now go and check you memory_limit 🙂


Due to the fact that most users didn’t understand the behaviour of the PHP GD library. Here an additional test I found on this discussion (taken form http://www.webmasterworld.com/php/3286309.htm ) :

During imagecreatefrom(type) calls, the memory usage is related to the number of pixels in the source image. So, it doesn’t matter if you have 3500×3500 pixels which are all the same color or 3500×3500 pixels of random color noise, the memory allocation will be identical with gd. You can test it by making two JPEGs which are of equal pixel dimensions but dramatically different file sizes then run each through this script.


ini_set(&#039;memory_limit&#039;, -1);
echo &#039;Start: &#039;.memory_get_usage().&#039; <br />';
$filename = '/path-to-your-file/3500x3500-72.jpg';
$im = imagecreatefromjpeg($filename) or die ("Cannot Initialize new gd image stream");
echo 'ImageCreate: '.memory_get_usage().' <br />';
echo 'ImageDestroy: '.memory_get_usage().' <br />';

I ran a 72 KB 3500×3500 JPEG and a 904 KB 3500×3500 image and both used up just under 62 MB of memory (61,392,088 bytes to be exact).


11 thoughts on “What's behind tera byte ?

  1. alakhnor says:

    It also depend on which php you’re running^^

    php5 uses more memory.

    For thumbnails, you need to destroy the img as soon as its usage is over. I’ll have to check this too.^^

    10.8 Mbyte doesn’t seem much, but it would worth have a look at peaks. 🙂

  2. alex.rabe says:

    Yes, a destruct is important, but it will not cure the problem of imagecreatefromjpeg() , this function requires still memory and you need to reserve it.

  3. Pavan Chander says:

    Ok so now I am a little confused, does the uploading fail because the server is taking up more memory then PHP can handle?
    My Server Settings page lists PHPs memory limit at 40MB, Upload at 20MB, post at 8MB.
    Currently the only way I can upload images into a gallery is to upload a zip file, all other methods i’ve tried fail.

  4. alex.rabe says:

    Please request further support via the forum. Thanks

    A memory_limit of 40MB should not cause any problems, it’s more than enough. Do you try to upload very large pictures ?

  5. […] you read this article : http://alexrabe.de/2007/06/08/whats-behind-tera-byte/ you can see that I have under Apache 2.0.48 / PHP 4.3.x (doesn’t remember) around 10,7 MByte […]

  6. winand says:

    Where can I find the two ‘Server settings’ screens as shown in this article?
    I want to check my memory usage

  7. jan says:

    @winand: Click the gallery tab. The first page contains the NextGen Gallery Overview including the server settings.

  8. Damian says:

    I’m still confused. So the server settings offer lots of info, however, does that mean that we have to go into our PHP settings within our servers to increase the mb limit, or is this something we can do within wordpress?


  9. mEsoL says:

    argh, so frustrating. i’m looking for wordpress gallery over a week. each of them have thier own problem. for nextgen, with memory limit. i’m wondering why. my server capable to handle up to 128mb memory limit but still have this kind of problem. why? why? why?

  10. dfeijy says:

    I just started to use this plugin, but I got the same problem too.
    Server Settings
    Here’s my server information

    * Operating System : Linux
    * Server : Apache/2.0.61 (Unix) PHP/4.4.7 mod_ssl/2.0.61 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2 SVN/1.4.2
    * Memory usage : 8.72 MByte
    * MYSQL Version : 5.0.24a-standard-log
    * SQL Mode : Not set
    * PHP Version : 5.2.3
    * PHP Safe Mode : Off
    * PHP Allow URL fopen : Off
    * PHP Memory Limit : 90M
    * PHP Max Upload Size : 7M
    * PHP Max Post Size : 8M
    * PHP Max Script Execute Time : 30s
    * PHP Exif support : Yes ( V1.4 )
    * PHP IPTC support : Yes
    * PHP XML support : Yes

    according to the memory limit, it is 90M, is that to small to upload a picture which is only 145kb?

  11. David says:

    I have tried uploading my first image but get an error message Exceed Memory Limit Require 63.78mbyte. Can I have help on how to increase the limit?

Comments are closed.

%d bloggers like this: