• qlddrones

    (@websupportguy)


    I have recently moved hosting company and my new host has a memory limit of 192MB which I am struggling to stay inside. I’m working on ways to do that, but meanwhile I desperately need to know if there’s a way to trap an Out of Memory error and use it to force a page refresh.

    I know they can be trapped because there are memory usage plugins that still show data to admin when an OOM occurs. I just don’t know how they do this or if it can be done outside of an admin login.

    I am not a programmer, just a HTML developed with some coding experience. So if you could keep it simple for me that would be really appreciated.

    Also if you have any advice on tracking down the cause of high memory use, that would also be great. The average use is only about 50MB and I’m not sure why it spikes out to over 230MB now and again. Could it be just concurrent use? Or is it likely to be a script or plugin?

Viewing 1 replies (of 1 total)
  • I have this in my theme’s functions.php:

    function memory_stats()
    { // BEGIN function memory_stats
          echo '<p style="clear: both;">Memory used: '. number_format(memory_get_usage(true)). ' bytes.<br />';
          echo 'Peak Memory used: '. number_format(memory_get_peak_usage(true)).' bytes.</p>';
    
    } // END function memory_stats
    
    add_action('in_admin_footer', 'memory_stats');

    That will tell how much PHP is using in the admin backend. You can make a call to memory_stats() in your theme’s footer.php as well to see how much memory the front-end uses.

    Also, might put an info.php file in your blog’s directory with the following:

    <?php
    phpinfo();
    ?>

    Then execute it and see what the memory_limit value is for PHP.

Viewing 1 replies (of 1 total)
  • The topic ‘How to detect "out of memory" error and force refresh?’ is closed to new replies.