Bobcares

Magento PHP memory limit – How to set the right value?

by | Nov 18, 2019

Are you fed up with the Magento PHP memory limit errors?

Insufficient PHP memory limit often results in the error Allowed memory size of XXXX bytes exhausted.

The fix involves increasing the memory allocated to the right PHP version in the server.

At Bobcares, we often get requests from our customers to increase the PHP memory limit in Magento 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.

Magento: Allowed memory size exhausted! Why?

The Magento PHP memory limit sometimes throws an error Allowed memory size exhausted either in the log file or while accessing the website.

By default, the memory_limit value in the PHP configuration determines the amount of memory allotted for the PHP script.

Often customers set insufficient values in the PHP configuration. Thus, during a fresh installation, even the readiness check display the error message:

 

Magento PHP memory limit

Similarly, when the PHP scripts are resource-intensive, we can also find the error in the log file of the website as follows:

The error message indicates that by increasing the global memory_limit in the servers php.ini configuration file we can fix this problem.

 

Methods to fix Magento PHP memory limit error

The releases of Magento1 and Magento2 differ slightly.  Magento 2 is the new version and it supports the latest PHP. It also improves the overall speed of the site. It can take more orders per hour and page loads faster than Magento 1.

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

Now, let’s see, how our Support Engineers fix this error by increasing the PHP memory limit.

Initially, before editing a configuration file, we always take a backup of the file. If anything goes wrong, this helps to easily restore it.

 

1. Editing php.ini file

The Magento documentation recommends at least 64MB as a default memory limit, then we can increase it according to the requirement.

The Magento 2 requires the memory_limit to be set to 756M or more.

Recently one of the customers was facing the same problem while upgrade from Magento CE 2.1.5 to 2.1.9 using Magento  Updater.

After completing the readiness check the customer was continuously receiving the following error:

"Your current PHP memory limit is 2048M. Magento 2 requires it to be set to 756M or more. As a user with root privileges, edit your php.ini file to increase memory_limit. (The command php --ini tells you where it has been located.) After that, restart your web server and try again."

We assisted the customer by editing the servers php.ini configuration file by making the memory_limit to 756M. The easiest and common way to change memory_limit is via editing php.ini.

1. We searched the memory_limit option in the php.ini file and edited it to 756M.

memory_limit = 756M

2. After that, we saved the file.

3. Finally, we restarted the Apache using the following command:

httpd restart

This resolved the problem with the memory limit, and we helped the customer to upgrade from Magento CE 2.1.5 to 2.1.9.

 

Altering .htaccess file

In addition to this, when PHP runs as a DSO module, increasing memory_limit involves editing the .htaccess file.

Magento has a default .htaccess file in the root directory that includes the following configuration directive.

php_value memory_limit 64M
php_value max_execution_time 18000

We then simply edited this value from 64MB to 96M or 128MB depending on the requirement. In all instances, our Dedicated Engineers double-check the phpinfo page and ensure that the new values show up.

 

[Need assistance in changing the PHP memory limit? We’ll help you.]

 

Conclusion

In short, the fix for the Magento PHP memory limit exceeded error involves increasing it by altering the value in php.ini, .htaccess, etc. Today, we saw how our Support Engineers changed the PHP memory limit in Magento.

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