We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23324
    • 40 Posts
    Hi,

    I have multiple modx websites running on a VPS with csf/lfd plugin installed and i'm getting these error mails regularly.
    It happens to different sites, on different times and it allways refers to public_html/index.php
    Is this a normal amount of memory a modx Revo site uses? Or nothing to worry about.
    Any ideas how to lower the memory size?
    Could it be that a plugin is causing the problem?
    The sites doesnt have that many visitors and are basic small company websites, with basic plugins installed, such as wayfinder, getresources, redactor, .....

    Thanks for any help!

    Time: Mon Jan 19 21:41:37 2015 +0100
    Account: ****
    Resource: Virtual Memory Size
    Exceeded: 320 > 200 (MB)
    Executable: /opt/php52/bin/php-cgi
    Command Line: /opt/php52/bin/php-cgi /home/***/public_html/index.php
    PID: 26410 (Parent PID:26330)
    Killed: No
      • 3749
      • 24,544 Posts
      Do you have a lot of conditional output modifiers or getResources calls that involve multiple TVs?
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 23324
        • 40 Posts
        Hi Bob,

        Thanx for your fast reply.

        I have no conditional outputs, there is 1 getResources call that includes TV's, but there is only 1 TV.

        I do have about 10 chunk calls, a gallery call and a callendar call.

        I can probably put some chunk calls together, but could that cause the high memory load?
          • 3749
          • 24,544 Posts
          I wouldn't think the chunks would take up very much memory.

          AFAIK, MODX Revolution itself only takes up about 8 or 9 Megabytes, so your figure seems excessive. Usually, about 120 megabytes is more than enough for even a fairly large MODX site.

          About how many resources is the getResources call processing and how big is the Tpl chunk it's using?

          I just ran a few tests with getCollection() and getResources() and couldn't get past about 17 megabytes.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
          • Do you have a recursion somewhere? Like a getResources snippet that outputs the content containing the getResources snippet?
              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
              • 3749
              • 24,544 Posts
              I think Susan has hit the nail on the head. It's likely that you have a loop somewhere such that the results of a tag contain the tag itself, so it loops until MODX notices the recursion and stops it.

              In the simplest form, it could be a chunk with a chunk tag for itself in the content. E.g., if you have a chunk called "SomeChunk" and you have this tag in the chunk:

              [[$SomeChunk]]



              Similarly, a getResources tag on a page that's under the &parents specified in the tag will also loop continuously.

                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
              • How are you measuring the memory usage Bob? I've got a few servers that would argue with the 17MB of ram or less theory.
                  Patrick | Server Wrangler
                  About Me: Website | TweetsMODX Hosting
                  • 3749
                  • 24,544 Posts
                  I'm checking with both of these:

                  <?php
                  $mem_usage = memory_get_usage();
                  $peak_usage = memory_get_peak_usage(true);
                  $output .= "\nBefore MODX Final Memory"
                      . ': ' . round($mem_usage / 1048576, 2) . ' Megabytes';
                  $output .= "\n" . 'Peak: ' . round($peak_usage / 1048576, 2) . ' MegaBytes';
                  echo $output;
                  


                  Is there a better way (or maybe my math is wrong)? [ed. note: BobRay last edited this post 9 years, 4 months ago.]
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 23324
                    • 40 Posts
                    Hi,

                    Thanx Susan and Bob, I did manage to find a 'loophole', it was a chunk in a chunk appearently!
                    Alltho i'm still getting the exact same amount of memory 320 MB usage on lfd-reports.

                    I checked the rest of the site for more 'loophole's, but couldnt find any.
                    The most complexed thing the site has is a chunck 'Top-banner' with a getResource to show the latest news and MXcalender-call to show the latest events.
                    GetResources searches about 20-25 resources, calendar about 30 items and pictures

                    Bob, i tried your code to see the memory usage on the site (it works if you remove the "*/" at the end fo your code), and with that i'm only getting a maximum peak of 20~25 MB.
                    But while i was checking every single page, i got an other lfd report saying it had 320 MB of Virtual Memory, so i really dont know anymore...


                      • 3749
                      • 24,544 Posts
                      I think my check shows only memory used by PHP. MySql and server processes may use memory that's not detected in my code.

                      Is the chunk tag for your top banner chunk containing getResources in the Template or the content field of pages?
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting