Bobcares

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 *

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

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF