We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14779
    • 256 Posts
    I got MaxiGallery working fine, but when I tried to upload a file, I get this error:

    Fatal error: Out of memory (allocated 35389440) (tried to allocate 12908 bytes) in /homepages/23/d193917934/htdocs/clearlyorganized/assets/snippets/maxigallery/watermark/Thumbnail.class.php on line 188

    The files are .png, less than 3MB
      PM me to find out how you can get a FREE ipad 2!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Check your phpinfo() for how much memory a process can use. Keep in mind that not only does MaxiGallery upload the file, it also processes it, with watermarks, backgrounds, shadows, etc... all of this takes up memory in excess of the actual image size. See the Wiki article:

      http://wiki.modxcms.com/index.php/MaxiGallery#Introduction

      More here:

      http://tikiwiki.org/tiki-read_article.php?articleId=82

      If you really want to know how PHP handles memory, try this:

      http://www.quepublishing.com/articles/article.asp?p=516587&rl=1

      And while doing a bit of quick Googling on the subject, I found this very interesting (although not completely relevant to the question here) idea:

      http://www.captain.at/ajax-file-upload.php
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 14779
        • 256 Posts
        memory_limit 40M
          PM me to find out how you can get a FREE ipad 2!
          • 7923
          • 4,213 Posts
          How many pics you are trying to upload at a time? What kind of snippet call you are using? Apache can also have memory_limit setting with "php_admin_value memory_limit"... I would think that 40MB is plenty though, My local settings has 8MB limit, but the thumbnail class rises it to 32MB. Of course, it still might not be enough if you are uploading 10x3mb images and there is some processing done to them.


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 14779
            • 256 Posts
            I’m just trying to upload one single image.
              PM me to find out how you can get a FREE ipad 2!
              • 4310
              • 2,310 Posts
              I’m posting here to continue/ shed some light on the same issue from here
              http://modxcms.com/forums/index.php/topic,12888.0.html
              I dropped the MG table in the DB and installed MG again, as suggested in another thread, and experimented uploading one JPEG image at a time gradually increasing in size.
              When I got to 300KB MG errored with a blank screen both in the manager and from the front end and failed to upload the image.
              By dropping the MG table again I managed to upload singly and in batches of 10 by keeping the size down to around 100KB (800 X 600).
              It seems as if the change in code affects some webhosts such as Heart Internet in the U.K. who I’m with.
              memory_limit	8M
              is what I get through phpinfo() in System Info via the manager.
              Regards
              David
                • 7923
                • 4,213 Posts
                Hmm.. I looked at the code and it probably is that there is an error in it.. In watermark/thumbnail.class.php in line 342-349 it says:

                        $memory_limit = ini_get('memory_limit');
                		if ($memory_limit < $this->memory_limit) {
                			ini_set('memory_limit',$this->memory_limit);
                		}
                        $max_execution_time = ini_get('max_execution_time');
                        if ($max_execution_time < $this->max_execution_time) {
                        	ini_set('max_execution_time',$this->max_execution_time);
                        }
                


                But that won’t work because the memory_limit setting is not a number but a number with M suffix. So to fix it temporarily, change that to:

                ini_set('memory_limit',$this->memory_limit);
                ini_set('max_execution_time',$this->max_execution_time);
                


                So the memory_limit will be always increased. I’ll fix that soon..


                  "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                  • 4310
                  • 2,310 Posts
                  Hi Doze,
                  Tried the fix for the Thumbnail.class.php file.
                  It helped me upload some 150 - 250KB JPEG’s singly and then in batches, then errored on a 350KB file!
                  Once it has failed you can’t upload anymore pictures, even smaller ones!
                  I tried it on a new gallery page without the dropshadow call but it failed first time on a 350KB file.
                  And then failed on every file I tried.
                  If I look in the gallery folder there is one picture, no thumbnail.
                  Regards
                  David
                    • 7923
                    • 4,213 Posts
                    And has the 0.4.1 work any better? Can you try with it now?


                      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                      • 4310
                      • 2,310 Posts
                      This is the current situation.
                      With webhost on PHP 4 or 5 and memory limit set to 8M
                      MODx 9.5 MG 0.41 JPEG > 200KB (approx) gives message
                      Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 8192 bytes) in /home/sites/crick.northants.sch.uk/public_html/assets/snippets/maxigallery/watermark/Thumbnail.class.php on line 183

                      MODx 9.5 MG 0.5 JPEG > 200KB (approx) errors to a blank screen with the standard Thumbnail.class.php
                      MODx 9.5 MG 0.5 JPEG > 200KB (approx) errors to a blank screen with Doze’s modification to Thumbnail.class.php file.
                      I’ve just tried using the same JPEG at higher and higher quality, starting at 100KB going up in steps to 800KB each of those loaded O.K. as soon as I used a different 500KB JPEG it errored!
                      With local machine using WAMP on PHP 5 and memory limit set to 8M
                      No problems using MG 0.41 or 0.5 with MODx 9.5

                      David