1

I'm running a Wordpress (WP) site and I am the root user of the VPS that is running right now.

So, when I am up to publish/create a new page it returns me the following message:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 72 bytes) in /home/.../public_html/wp-includes/compat.php on line 123

I have already search and read a various of articles about that problem. So I have done the following things:

From my whm -> php configs And I have allocate in memory_limit : 512M

Also, I have define at the top in wp-config.php file the following command:

define('WP_MEMORY_LIMIT', '512M');

However, I am still getting the error.

Additionally, I tried to insert the following in my .htaccess but it didn't work.

<IfModule mod_php5.c>
     php_value memory_limit 512M
</IfModule>

I have allocated more than 1GB but it didnt work.

Also, I have re-install the whole WP framework to the latest version.

Plus, I have restart the apache a couple of times to see the current setting on php, but i think that is not necessary. Right?

I have add the plugin: WP Overview (lite) to see the php allocation and I have that values:

Mem: WP 512M (def) Usage 16% 81.03M of PHP Limit 512M

Finally, I have created 2 test files to see the allocation:

File1:

<? phpinfo(); ?>

It returns that I have 512M php allocation which is correct.

File2: <?php echo memory_get_usage(); ?> which returns

213696

Is the this returning correct?? I thought that it should return 512M in bytes.. Right?

Any idea about the problem ? I am stacked on this issue.

Greg
  • 343
  • 3
  • 17
  • FYI `memory_get_usage()` ~ *"Returns the amount of memory, in bytes, that's **currently being allocated** to your PHP script."* – Phil Oct 06 '15 at 00:57
  • 1
    Just because you tell PHP that it's allowed to use 512MB, doesn't mean it will. You've just told it how much is allowed to use up before it *has* to crash its process for behaving improperly. The real question is: why is 268MB not enough for what you are doing? Under normal WP operation, there is no way for it to need that much memory. Did you install any funky plugins that make PHP behave in a way it's not supposed to? (PHP is a run-and-die technology: normal operation means it gets fired up to process a `.php` file, returns the processing result -if any- and then terminates again) – Mike 'Pomax' Kamermans Oct 06 '15 at 00:58
  • I have about 20 active plugins and a hard theme + 2 active user per 5 secs. So I need that memory.. also I think that my caching plugin consums the most php memory.. dunno to be honest. – Greg Oct 06 '15 at 01:00
  • If they're properly written plugins, that's still nowhere near enough to require over 200MB or ram during operations. Time to fire up your dev environment, turn off all your plugins, and start enabling them one by one with your process monitor open, to see which plugins are causing the massive memory usage. That'll give you a much better basis for figuring out how to *really* solve this problem, rather than to just increase the memory limit and hope for the best. – Mike 'Pomax' Kamermans Oct 06 '15 at 01:02
  • I suspect it's just Wordpress being very crap at handling very long strings ~ https://github.com/WordPress/WordPress/blob/4.3.1/wp-includes/compat.php#L123 – Phil Oct 06 '15 at 01:04
  • I had that WP site on a share host server and it didnt had any problem with the allocation.. Now I have moved it to a VPS and it has that issue.. So i think that it is not any problem for the WP framework but from the apache or php rules.. – Greg Oct 06 '15 at 01:07
  • Never trust your intuition: test your guesses, because until you do there is no reason for you to be right about them. Play around with your configuration to find out what can be ruled out, because ruling out possible causes means you have uncovered super important information that you can add to your question, so that people won't be focusing on parts that you've already determined don't contribute to the problem. – Mike 'Pomax' Kamermans Oct 06 '15 at 01:10
  • How much RAM is your VPS allocated? – Phil Oct 06 '15 at 01:13
  • 4GB . its plenty. @Phil – Greg Oct 06 '15 at 01:14
  • Solution found: http://stackoverflow.com/questions/32960516/php-allocation-doesnt-work?noredirect=1#comment53746381_32960516 But i still dont get why is that happend :) – Greg Oct 06 '15 at 03:05

0 Answers0