¿Ves un mensaje de error de tamaño de memoria permitido agotado en WordPress?
Este es uno de los errores más comunes de WordPress, y puedes corregirlo fácilmente aumentando el límite de memoria PHP en WordPress.
En este artículo, le mostraremos cómo corregir el error de memoria agotada de WordPress aumentando el límite de memoria PHP.
¿Qué es el error de memoria agotada de WordPress?
El error de memoria agotada de WordPress es un mensaje que puede aparecer si su sitio web tiene problemas para realizar tareas.
WordPress utiliza PHP, un lenguaje de programación del lado del servidor que necesita memoria para funcionar.
Al igual que cualquier otro ordenador, los servidores web disponen de una cantidad limitada de memoria para ejecutar varias aplicaciones al mismo tiempo. Los proveedores de alojamiento de WordPress asignan tamaños de memoria específicos a diferentes aplicaciones, incluido PHP.
Cuando su código WordPress requiera más memoria que la asignada por defecto, verá este mensaje de error:
Error fatal: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx
Es posible que su sitio WordPress esté agotando la memoria de su servidor:
- Muchas imágenes, vídeos y otros tipos de medios
- Muchos plugins de WordPress sin usar
- Se le han quedado pequeños los recursos de su plan de alojamiento
Por defecto, WordPress intenta automáticamente aumentar el límite de memoria PHP si es inferior a 64MB. Sin embargo, 64MB no suele ser suficiente.
Dicho esto, veamos cómo aumentar fácilmente el límite de memoria PHP en WordPress para evitar el error de memoria agotada.
Puedes utilizar los enlaces rápidos que aparecen a continuación para navegar por el tutorial:
Nota: Algunos de estos métodos requieren que edite directamente sus archivos de WordPress. Le sugerimos que primero haga una copia de seguridad de su sitio web para evitar que aparezcan más errores en su sitio web.
Opción 1: Editar el archivo wp-config.php
En primer lugar, debe editar el archivo wp-config.php en su sitio de WordPress. Se trata de uno de los archivos principales de WordPress situado en el directorio raíz, normalmente denominado public_html.
Tendrás que utilizar un cliente FTP como FileZilla o el gestor de archivos de tu panel de control de alojamiento web.
A continuación, tienes que pegar la siguiente línea en el archivo wp-config.php justo antes de la que dice, ¡Eso es todo, deja de editar! Feliz blog.
define( 'WP_MEMORY_LIMIT', '256M' );
Este código le dice a WordPress que aumente el límite de memoria PHP a 256MB.
Para más detalles, consulte nuestra guía paso a paso sobre cómo encontrar y editar el archivo wp-config.php.
Una vez que haya terminado, debe guardar los cambios y volver a subir el archivo wp-config.php a su servidor.
Ahora puede visitar su sitio WordPress y el error de memoria agotada debería haber desaparecido.
Opción 2: Editar el archivo .htaccess
El siguiente método consiste en editar el archivo .htaccess. Este archivo también se encuentra en la carpeta raíz del sitio web de WordPress.
Aquí, necesitas pegar el siguiente código antes de la línea que dice #END WORDPRESS
.
php_value memory_limit 256M
Similar al código anterior, le dirá a WordPress que aumente el límite de memoria PHP a 256MB.p
Después, simplemente guarde los cambios y vuelva a subir el archivo a su servidor web. Ahora puede abrir su sitio web WordPress de nuevo para ver si el error de límite de memoria ha desaparecido.
Si no encuentra el archivo .htaccess, consulte nuestra guía sobre por qué puede faltar el archivo .htaccess y cómo encontrarlo.
Opción 3: Comprobación del archivo php.ini
Si los métodos anteriores no funcionan, es posible que desee echar un vistazo a su archivo php.ini.
php.ini es un archivo que controla tu configuración PHP, incluyendo la versión PHP y los scripts PHP. No es un archivo del núcleo de WordPress, ya que normalmente lo gestiona tu proveedor de alojamiento.
Puede marcar / comprobar su código para ver su límite de uso de memoria PHP. Para más detalles, puede consultar nuestra guía sobre cómo encontrar y editar el archivo php.ini.
Sin embargo, dado que se trata de un método avanzado, le recomendamos que se ponga en contacto con el equipo de soporte de su proveedor de alojamiento web para ver si pueden aumentar el límite de memoria de WordPress manualmente. De lo contrario, podrían producirse más errores.
Puede leer nuestra guía sobre cómo solicitar correctamente asistencia de WordPress para obtener más información.
Opción 4: Actualizar el alojamiento de WordPress
Si se encuentra constantemente con el error de memoria agotada, podría ser una señal de que su sitio web ha superado su plan de alojamiento actual.
A medida que su sitio web atrae más visitantes y añade más contenido, requiere más recursos para funcionar sin problemas. Actualizar a un plan con una mayor asignación de memoria puede ser una solución permanente.
Considere la posibilidad de actualizar su alojamiento de WordPress si:
- Has probado las soluciones anteriores y el error persiste.
- Su sitio web ha crecido significativamente en tráfico o contenido.
- Tiene previsto añadir características o funcionalidades que requieren más recursos.
Bluehost ofrece planes de alojamiento para WordPress asequibles y fiables que se adaptan a las necesidades de su sitio web. Ofrecen una plataforma fácil de usar optimizada específicamente para WordPress, lo que facilita la gestión de tu sitio web.
Si utiliza nuestro Bluehost código de cupón, entonces usted puede conseguir hasta un 61% de descuento en su primera compra. Simplemente haga clic en el botón de abajo para conseguirlo:
Cómo evitar agotar la memoria de WordPress
Ahora que ha solucionado el error de memoria agotada de WordPress, aquí tiene algunos pasos proactivos para evitar que vuelva a ocurrir:
- Desactive los plugins que no utilice. Muchos plugins contribuyen al consumo de memoria. Revisa regularmente los plugins que tienes instalados y desactiva los que no utilices para liberar memoria para tareas esenciales.
- Optimiza las imágenes. Las imágenes grandes pueden consumir mucha memoria. Considera usar un plugin como EWWW Image Optimizer para comprimir automáticamente las imágenes antes de subirlas a tu sitio.
- Utiliza un plugin de caché. Los plugins de caché almacenan los datos del sitio web, reduciendo la necesidad de que WordPress los regenere en cada visita. Esto puede mejorar significativamente el rendimiento del sitio web y reducir el uso de memoria.
Esperamos que este artículo te haya ayudado a solucionar el error de memoria agotada de WordPress aumentando el límite de memoria PHP. Puede que también quieras ver nuestra guía paso a paso para principiantes sobre cómo solucionar errores de WordPress y nuestras selecciones de expertos sobre los mejores plugins de WordPress para hacer crecer tu sitio.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
mohadese esmaeeli
With your permission, I’d like to add a note for users to the article:
Please note that htaccess is a hidden file. First, check if it exists. In case you couldn’t find the .htaccess file in your hosting, you can create one using text editor programs like Notepad. Simply create a file named htaccess. Alternatively, in the public_html directory, click on “New File” and create a file with the same name.
mohadese esmaeeli
I have encountered this issue multiple times, and it seems to be one of the most common problems in the WordPress domain. Each time, I either contacted the hosting support or edited the htaccess file to resolve the issue. The htaccess file appears to be like a magic solution, and whenever an issue arises, it can be quickly reviewed and fixed.
Mrteesurez
I used to encounter some errors like this on my websites but I didn’t know what to do. Something when I tried to solve it, I just uninstall the step and re-install it back and upload the backup.
I noticed the problems still persist, when I enable wp debug mode, t then see the exact errors and the it’s source.
I later find this guide and implented it and it works.
Thanks.
WPBeginner Support
Glad to hear our guide was helpful!
Administrador
karma tsheten
AFter updating my .htaccess it gives me this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
WPBeginner Support
To be safe, for the internal server error we would recommend going through the steps in our article below:
https://www.wpbeginner.com/wp-tutorials/how-to-fix-the-internal-server-error-in-wordpress/
If removing the code from the htaccess solves the issue, we would recommend reaching out to your host to see if they have a setting that could be the source of the conflict.
Administrador
Jiří Vaněk
Regarding the .htaccess file, be cautious. Many shared web hosting providers may have directives for increasing the memory limit disabled. Such a directive in the .htaccess file can cause a 500 error on the website, requiring its removal or commenting out. Be careful with this. Sometimes, simply increasing the memory limit may not solve the problem but rather delay it, like a painkiller. The pain might subside, but it doesn’t mean the cause has been resolved. Therefore, while increasing the memory limit might seem like a solution, it’s also important to check what is consuming the memory. Sometimes, people increase the memory limit from 512 MB to 1024 MB without considering whether it’s necessary, and whether the memory limit isn’t masking an underlying issue on the website.
WPBeginner Support
Thank you for sharing your feedback on the htaccess change. Unless the host has very strict rules in place adding to the htaccess shouldn’t cause an error it is more likely to not work and would require you reach out to the host to request an override.
Administrador
ROOK
SAVED THE DAY!! TY
WPBeginner Support
Glad our guide could help!
Administrador
Qamar Shafique
Thanks for this help.
WPBeginner Support
You’re welcome!
Administrador
Aisha
It doesn’t solve my problem still shows an error after placing the code “define( ‘WP_MEMORY_LIMIT’, ‘256M’ );” and I also change the size of Memory_limit of Php.ini file
WPBeginner Support
As we state in the article, if our code does not work, there is a good chance your hosting provider is overriding the memory limit and you would need to reach out to your host to fix the error.
Administrador
Sohaib Siddiq
It doesn’t solve my problem still shows an error after placing the code “define( ‘WP_MEMORY_LIMIT’, ‘256M’ );” & this is my front-end page showing
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 8192 bytes) in /home/X/wp-includes/class-wp-dependencies.php on line 260
WPBeginner Support
If the code does not work for you, we recommend reaching out to your hosting provider as they may have a limit set on their end that could be the root of the issue.
Administrador
Zachary Murri
Thank you so much <3
WPBeginner Support
You’re welcome
Administrador
Bogosi
Thank you for this!
WPBeginner Support
You’re welcome!
Administrador
Devox
Super! it solved the problem quickly ,thank you very much
WPBeginner Support
Glad our guide was helpful!
Administrador
Ifedayo
Thank you, this was helpful! All problem has been solved by carefully following this step-by-step instructions. Keep up the good work
WPBeginner Support
Glad you found our guide helpful!
Administrador
John
Thanks very much. It was very veryhelpful.
WPBeginner Support
Glad our guide was helpful!
Administrador
Michie
Your website is beneficial, especially to a beginner like me. Thank you so much
WPBeginner Support
Glad you found our guides helpful
Administrador
Doy
Hi,
Thank you for this awesome website. I got this in the error log after adding this code.
[26-Apr-2022 02:45:31 UTC] PHP Warning: Use of undefined constant ‘WP_MEMORY_LIMIT’ – assumed ‘‘WP_MEMORY_LIMIT’’ (this will throw an Error in a future version of PHP) in /wp-config.php on line x
Is this a problem? Should I remove the code?
WPBeginner Support
That would only be an error for future versions of PHP. This solution should only be a temporary fix and your hosting provider should be able to assist with the root cause of the issue.
Administrador
Alison Taylor
Thank you! You folks rock. This solved my problem. WPBeginner is my go-to website for learning new things about WordPress, even though I’m not a beginner.
WPBeginner Support
Glad our guide was helpful
Administrador
J h
“Once you are done, you need to save your changes and upload your wp-config.php file back to your server.”
How again do you upload the file back to your server?
WPBeginner Support
You would need to use FTP or your host’s file manager again and there should be the option to upload and replace the file
Administrador
Daniel
The changes are not having effects. We are still with 40MB and the site does not accept the changes. What should I do?
WPBeginner Support
As we state at the end of the article, if our recommendations do not work, please reach out to your hosting provider as they may have set a limit that would override what you as a user can set.
Administrador
Liviu
Really worked.
I had white screen when I wanted to create a new post on PC browser. But worked on my phone.
Thanks
WPBeginner Support
You’re welcome
Administrador
Simeon Adedokun
Thank you so much for this! It’s really helped me.
WPBeginner Support
Glad our guide could help
Administrador
John Harries
Thank you for providing a straight forward solution to an error which occurred when I tried to update the php version from 7.1 to 7.4
Mart
Fantastic, thank you soooo much for this, simple straight talk.. excellent.. first problem solved … now got to learn more
WPBeginner Support
Glad our guide was able to help
Administrador
Julian
I had to change mine to much higher and hope it won’t cause an issue? Changed to 1024M!
WPBeginner Support
It can mean the site can take longer to notice issues if some arise but shouldn’t cause a major issue in general.
Administrador
Mujahid Siyal
I added the code problem is gone but a text “WP_MEMORY_LIMIT” has appeared in the top corner of logo. So what should I do about that?
WPBeginner Support
You would want to ensure you added the code snippet correctly as it is likely showing that code thinking it is text.
Administrador
David
“First you need to edit the wp-config.php file on your WordPress site. It is located in your WordPress site’s root folder, and you will need to use an FTP client or file manager in your web hosting control panel.”
Simple! What does that mean? It is gobbledegook to me.
WPBeginner Support
For using an FTP client we would recommend taking a look at our article below for a better understanding on the subject:
https://www.wpbeginner.com/showcase/6-best-ftp-clients-for-wordpress-users/
Administrador
Anna yakub
This was super helpful for an issue I’ve battled with for a while now. Thanks so much
WPBeginner Support
Glad our recommendations were helpful
Administrador
Katerina
I’m new in WordPress and I’m trying to figure out, for a couple of days, why suddenly I get an error 500 and can’t save my edits. This helped solve my problem. Thank you so much!
WPBeginner Support
Glad our guide could help
Administrador
Richard Lamsdale
Thanks for this – it fixed my problem.
WPBeginner Support
Glad our guide was helpful
Administrador
Malou
Helpful, Thank you so much
WPBeginner Support
You’re welcome
Administrador
Segun
This worked perfectly for me. Thanks
WPBeginner Support
You’re welcome
Administrador
Rick Richi
can I increase the memory to 512?
WPBeginner Support
You can certainly try to see if that fixes the error for you.
Administrador
Haris imran
Thanks it helped me a lot
WPBeginner Support
Glad our guide was helpful
Administrador
Arpita Hunka
This solution is not working for me, my website is hosted at AWS server and I have all the access, I have tried to set memory_limit in php.ini, wp-config and .htaccess. but still getting issue when accessing backend pages.
WPBeginner Support
You would want to reach out to the support for your hosting for what other options you have available with AWS
Administrador
Anders
Thanks a lot….
A quick and easy fix!!
WPBeginner Support
You’re welcome, glad our guide was helpful
Administrador
Faisal Arafin
You just saved me from heart attack…..
WPBeginner Support
Glad our guide could help
Administrador
Laura
Thaaaanks, you save my day!
WPBeginner Support
You’re welcome
Administrador
Benthe Kuijpers
Thanks so much! Was so worried when I had this fatal error, but this fix is just a piece of cake!
WPBeginner Support
Glad our guide was helpful
Administrador
Dileepa K
Thank you for this post…
Very Helpful
WPBeginner Support
You’re welcome
Administrador
Gunvant Nakum
Thanks you so much for your help
WPBeginner Support
You’re welcome
Administrador
Sumit Gupta
This is not working for me.
WPBeginner Support
If our recommendations are not working, you would want to reach out to your hosting provider and they should be able to assist
Administrador
Ademola Kayode Abdulai
this still works after few years,, Great thank you… works for me as well
WPBeginner Support
Glad our recommendation was helpful
Administrador
Luuk
Great tip! Thank you very much!
WPBeginner Support
You’re welcome
Administrador
Mehedi Mahmood
Thank you so so much! can’t really explain how helpful this was
WPBeginner Support
Glad our guide was helpful
Administrador
Manthan Admane
Thank you so much.
Solved my issue
WPBeginner Support
Glad our guide was helpful
Administrador
Mevlut Demiroz
Very thanks, fixed
WPBeginner Support
Glad our guide was helpful
Administrador
Ivan
Hi, I had the memory exhausted message and I increased the wp memory limit to 12mb and it worked. Then a few days later I had the same error, so I had to increase the wp memory limit to 256mb and the message kept showing. I am currently on 1024mb, which seems excessive for a small website of 4 pages and a blog post of 15,000 words. Any suggestions how to resolve the issue or what might be causing it?
WPBeginner Support
You would want to reach out to your hosting provider and they can normally assist in finding the root of the issue for your specific site.
Administrador
player
thank you so much.
WPBeginner Support
You’re welcome
Administrador
Mathilda
thanks so much!
WPBeginner Support
You’re welcome
Administrador
Sone Eric
Thank you very much. You solved my problem.
WPBeginner Support
Glad our article was able to assist
Administrador