• I tried for a day to apply define(‘WP_MEMORY_LIMIT’, ‘512M’) in my wp_config.php. I also have memory_limit = 512M in my php.ini.

    But the setting was ignored by WP. After much much investigating I have found this in wordfence code.

    if((int) @ini_get('memory_limit') < 128){
           if(strpos(ini_get('disable_functions'), 'ini_set') === false){
                  @ini_set('memory_limit', '128M'); //Some hosts have ini set at as little as 32 megs. 64 is the min sane amount of memory.
           }
    }

    That for some reason is fired also in with phpinfo() I have 512M as LOCAL VALUE and MASTER VALUE memory_limit.

    https://wordpress.org/plugins/wordfence/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter Ciao121

    (@ciao121)

    Sorry, the last sentence had to be:
    That code, for some reason, seems to be fired also if I have 512M as memory_limit both as LOCAL and MASTER VALUE in phpinfo().
    So in wordpress I’m stuck at 128.

    Man, this is kicking my butt, too. It’s been going on for a few days now. I’ve done everything that has been suggested to increase the memory limit and and phpinfo clearly shows I’ve got plenty of memory but…

    ‘ Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 4025073 bytes) in /home/andthatsthenews/public_html/wp-includes/wp-db.php on line 1129’

    …and WordFence is crashing, as you can do the math, at 16.67MB requested.

    So, what now??

    Hi,

    Check with your hosting provider and see how much memory they have allocated to your site. You may need to get them to make an adjustment for you.

    -Brian

    Thanks, WFBrian.

    GoDaddums confirms there is 256M available, which matches the phpinfo.php return.

    I’ve tried using php4, php5 and their “native” php5.4 (5.4.43). I’ve turned off all plugins individually and by temporarily renaming the plugins directory. Between each action, I killed off all php processes.

    I’ve also turned off all comments, just in case that interferes.

    Very frustrating!

    And I should mention I have removed WF, cleared all transient cache and reinstalled WF.

    I’ve set the maximum execution time of each script to 120 seconds, increased the amount of time each script may spend parsing request data to 60 seconds and upped the maximum allowed size for uploaded files to 32MB. With the exception of setting ‘memory_limit = 256M’ in /public_html/php.ini (which I learned here on another thread from some other bright folks), all of the above I did as a tech at GoDaddums held my hand. Unexpected from them, but very nice!

    Speaking of very nice, WF has done a yeoman job of protecting my site since its inception and has never failed me before.

    And maybe I shouldn’t mention this word here but, while I was concerned there was something malicious doing something unsavory, I did DL and install—to make a single scan—that Securi plugin. Once it said “all clear” it was out of there …and I hope WF can be returned to working properly.

    Oddly, this all began just a few days ago without any prodding. That is to say, no new plugins, no changes to other programs, and only one or two posts.

    Your thoughts? Much appreciated.

    -Gurn

    Thread Starter Ciao121

    (@ciao121)

    Blanston,
    have you tried to change the value in that code:
    @ini_set(‘memory_limit’, ‘128M’);
    in wp-content/plugins/wordfence/wordfence.php?

    Hey Ciao,

    I did manage to get that ini_set command to save in wordfence.php but, I am still getting the Fatal Error on scan in the exact same place (line 1129)! I upped it to match the 256M specified everywhere else.

    I ‘spose I could try changing everything to 512 but, since everything has worked perfectly up to a few days ago and this suddenly appeared, I hesitate to continue to chase problems that don’t appear to be, well, me.

    As WF appears to be catching violators just fine, as always, I guess it’s time to give up on scanning and wait until an update is released, to see if that solves the issue.

    Thanks for your help. I will continue to read any follow-ups, in case anyone has another idea.

    -Gurn

    Plugin Author WFMattR

    (@wfmattr)

    Hi,

    Catching up here — I haven’t seen this happen in practice, but I’ve heard that if the host uses “suhosin” for additional PHP security, memory can be limited in the suhosin settings as well. The “Allowed memory size of 67108864” error is only 64 MB, so it does sound like something else is changing it before Wordfence tries to increase 128M.

    Depending on the server’s setup, you might be able to see suhosin’s config by clicking the link near the bottom of the Wordfence options page that says “Click to view your system’s configuration in a new window”.

    This link also lists which .ini files are loaded by PHP, which might help track down another file where the limit is set. On some versions of PHP, this page might not show all of the details of all of the PHP extensions — if it’s a very long page, try just searching for “suhosin” and see if there is a mention of another memory limit there.

    -Matt R

    Hello Matt.

    I realize it’s been a couple months now but, I just wasn’t getting anywhere and spending way too much time chasing down this problem—since I’ve done everything to mitigate this issue, including spending hours and numerous phones calls to the host’s tech.

    My scans are still freezing with “Fatal error: Allowed memory size of 67108864 bytes exhausted.”

    However, I may have found another glitch in WordFence: The error occurs now in “wp-content/plugins/wordfence/lib/wordfenceHash.php” on line 337. When I set an exclusion to skip this file in Options, scans still jam up on the excluded file!

    Weird eh?

    Not only is WF failing on an excluded file, the file belongs to WF!

    Guess it’s time to give up on this endeavor and forget about scanning!

    Thanks for your reply, though.

    -Gurn

    P.S. No “suhosin” found anywhere.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Memory_Limit’ is closed to new replies.