We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22656
    • 121 Posts
    Got 2 MODx sites (2.1.3) running on a dedicated windows server 2008 box. One seems to be absolutely fine, however the second one keeps reporting out of memory issues:

    PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 40 bytes) in \core\model\modx\modx.class.php on line 2032
    PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 43 bytes) in \core\model\modx\error\moderrorhandler.class.php on line 70

    I have attempted increasing the PHP memory limit from 128MB to 256MB, the problem persists.
    Anyone knows how can I troubleshoot this particular problem? The site itself still seems to be running fine despite these errors flooding the logs.

      • 22303 MODX Staff
      • 10,725 Posts
      Something is definitely causing the out of memory errors, but it's not obvious why. Can you tell what request is triggering the error?
        • 22656
        • 121 Posts
        Not sure how I can find out?
        Just looked into logs, for the same timestamp, I can see a request for index.php starting before and continuing after the same timestamp:

        /index.php q=fancybox/fancy_shadow_s.png

        [ed. note: papachumba last edited this post 14 years, 9 months ago.]
          • 22303 MODX Staff
          • 10,725 Posts
          Did that link get formatted correctly? If not put it in code tags here in the forum...
            • 22656
            • 121 Posts
            Changed.
            Been looking at the logs, traffic was high for most part of the day so I will have another look in the evening and try to match up various requests vs error log timestamps.

            From what I could gather so far, it happens when someone requests a page.
            Turning this around on its head - can I use anything to monitor script's memory usage? I could then perhaps use this to work out which snippet might be responsible for this (if it is a snippet)

            I have migrated the site to MODx 2.2 on my localhost, and cannot trace the same error, however thats a different setup altogether.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Are your pages fetching image thumbnails or other images being processed by phpthumb? That sort of thing can take up a lot of memory.
                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
                • 22303 MODX Staff
                • 10,725 Posts
                That link indicates the image file was not found and the request is loading the MODX error_page in place of the image. Make sure you don't have missing images.
                  • 22656
                  • 121 Posts
                  Argh, found it, just been snooping around the logs. I think its from one of the custom snippets we created, not php thumb or modx itself.
                  Yandex bot hits a particular page around every 3 minutes (acc to logs). One of the querystring params had a space at the end of it, which caused an endless loop. I can recreate the error, will tie down the querystring param tommorow, thanks for the input! [ed. note: papachumba last edited this post 14 years, 9 months ago.]
                    • 22303 MODX Staff
                    • 10,725 Posts
                    One thing you can do if not serving any image files from MODX as static resources is exclude files by extension from the MODX rewrite rules for friendly_urls.

                    RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]


                    This should go before the RewriteCond and RewriteRule expressions for MODX friendly_urls.
                      • 22656
                      • 121 Posts
                      Oh, cool Opengeek.
                      So basically this alleviates the modx 404 error page for missing imagery and presents the original server's 404 instead? (as far as I could gather, after testing)