wesupport

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

PHP memory limit in Drupal – Different methods to alter the settings

by | Nov 8, 2019

Have you ever thought your Drupal PHP memory limit played a major role in the performance of the website?

Often, an error like "Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes) can occur due to insufficient PHP memory limit.

Also, this error signifies that Drupal required more memory than PHP was allowed to give it. Therefore, increasing the PHP memory limit helps to resolve the error.

At Bobcares, we often get requests from our customers to increase the PHP memory limit in Drupal as part of our Server Management Services.

Today, let’s get into the details on how our Support Engineers increase the PHP memory limit and fix related errors.

Need for PHP memory limit in Drupal

PHP makes it possible to use a default amount of memory while loading a website. In Drupal sites, the standard PHP memory requirements are very less. However, when the sites that run many contrib modules, or particularly memory-intensive ones.

At those times, we may get a white screen on the website or get the following error when uploading a file or running simultaneous processes.

Therefore, one way to fix the error is by increasing the PHP memory limits.

So, let’s see how our Support Engineers fix the error by using different methods.

 

PHP memory limit Drupal – How we fix it

At Bobcares, where we have more than a decade of expertise in managing servers, we see many customers face problems with the PHP memory limit.

Now, let’s see the major reasons for the Error: Memory Size Exhausted and how our Support Engineers fix this error by increasing the PHP memory limit.

 

php.ini

This is one of the best methods to change the PHP memory limit in Drupal. We are changing the value in the server’s php.ini. So, This is advisable only in dedicated or VPS servers. Also, this change will affect all websites and PHP scripts on the server.

So, our Support Engineers make sure that the memory_limit parameter has set to enough memory value. If not, we edit the memory_limit parameter in the php.ini file. In addition, we make sure you use M to specify the number of megabytes.

Unfortunately, some server doesn’t have this section. Then, we add the following line at the end of the file.

memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)

That’s it.

 

php.ini in the Drupal root folder

Another way to change the PHP memory limit is by adding the following line to a php.ini file in the Drupal root folder.

memory_limit = 64M

But, it will only work if PHP is running as CGI/FastCGI.

 

Through a hidden file .user.ini

Similarly, another useful file for changing the PHP memory limit is .user.ini. This is a hidden file that is located in the public_html folder.

If it is not in the public_html folder, we simply create the .user.ini file and add the following line to it.

memory_limit = 64M

 

.htaccess

Again, when the PHP is running as an Apache module, we can change the PHP memory limit via .htaccess file in the Drupal root directory.

We add the following line in .htaccess file.

php_value memory_limit 64M

 

Settings.php

When the Drupal is already installed, we can edit the file settings.php located in sites/default/. This approach will affect only the site using this file.

To change the PHP memory limit. We locate the PHP settings section and add the following line at the end of that section.

ini_set('memory_limit', '64M');

These are the various method to change the PHP memory limit.

 

[Need assistance change PHP memory limit? We’ll help you.]

 

Conclusion

In short, when the Drupal required more memory than PHP allowed, we can increase it in different ways such as alter the value in php.ini, .htaccess, .user.ini, etc.  Today, we saw how our Support Engineers changed the PHP memory limit in Drupal.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags