I'm getting this nasty error Fatal error: Out of memory (allocated 18087936) (tried to allocate 77824 bytes)
. Weird thing is, it's 17,25 mb (allocated) and it tried to allocate 76 kb. Memory limit is 128MB, and as you can see it's not even close to that. VPS got ~400mb of free ram at that moment. It only happens when I'm posting something and not all the time.
I find it weird and don't really know what can cause it.
Let me know if you need any additional info.
The error says that the memory limit is 18M and not 128M. This means that somewhere the memory_limit is set to something different than 128M (local php.ini, or the application itself, since PHP can override this setting at run-time).
I would suggest that you first create a file called (say) phpinfo.php with the following contents:
<?php
phpinfo();
?>
and place it where your script runs. Then access the file with your browser and look for the actual memory_limit value. If it's still showing 128M both for "global" and "local" value, then probably somewhere in your code, there's a "ini_set("memory_limit", $value);" call or something similar. Otherwise, if it says 18M, look for other places where this can be set:
Hope this helps, as I had the same issue:
You're running into a limitation in WordPress's own memory limit, not your PHP memory_limit. Wordpress implemented this limit in order to prevent poorly written scripts from shutting down your whole PHP interpreter. Unfortunately, as you've noticed, it's rather barebones.
The easiest way I've found to fix this is to install the Change Memory Limit plugin from Wordpress plugin repository. It allows you to fix the issue without modifying any WP files manually.
The 64M default for the plugin will probably be fine for you.
Alternatively, if you don't want to trust a third party plugin, add the following line to wp-config.php
:
define('WP_MEMORY_LIMIT', '64M');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With