3

I'm new to Magento and I can see that it is a sophisticated system with a lot of depth, but I've come across many headaches since switching to it from OpenCart. The first and foremost is this error that I get when trying to add a product:

"Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 139564 bytes) in /home/vainlane/public_html/mag/app/code/core/Mage/Core/Block/Abstract.php on line 944"

In the htaccess there are these lines:

php_value memory_limit 512M
php_value max_execution_time 38000

I modified the original 256 to 512, but no difference. Can anybody point me in the right direction here? Pretty stumped. I'm using this installation on a cPanel configuration on reseller hosting.

  • 2
    Create a seperate php file called php.php and put in it <?php phpinfo(); ?> . While you may have changed it in your .htaccess, The server's php.ini may prevent it from going to a higher value. – kab8609 Jul 28 '14 at 22:49
2

Hard Coded 32M memory_limit.

If you are running this off a shared server, your memory_limit may be locked down to 32M so you're forced to fairly share resources with others on the server. Magento doesn't run well on shared servers that have not been optimized for Magento, btw.

Your web server may not be set up to use memory_limit out of .htaccess and thus requires you to use a php.ini file to set memory. See the php.ini.sample file that Magento installs in its root folder for what the php.ini file contents need to be.

Otherwise, check with your hosting service provider and ask them to bump the limit to 512M.

  • Thanks, this is pretty much it. I requested that the host increase the memory and they did so. I looked at the requirements for Magento and the memory limit still isn't being met, but at least it's working. That's good for now, at least. – Richie-Rich Powell Jul 30 '14 at 22:18
2

You may fix it temporarily by adding this line in your index.php

ini_set('memory_limit','512M');
  • I have checked the php.ini, the .htaccess and the index - used multiple examples I've seen on the internet. I have pushed the memory size up to 8192M and it still runs out. I ask again, why is this thing so top-heavy? – Scott Nov 13 '17 at 21:02
  • I should add, the amount used increases with my changes, so my changes are working. It still exhausts all available resources. I'm trying to figure out how to mirror a server on another platform and any time I try to replicate an install on the other platform, I run into these memory problems sooner or later. This last time, I did a brand new install and manually replicated the configuration. It was working fine Friday, this morning, it's spitting out of memory errors again! – Scott Nov 13 '17 at 21:04
1
Allowed memory size of 41943040 bytes ...

... indicates to absurdly low memory limit of 40MB or so (Magento should have no less than 256MB, 512MB or more being recommended value).

Memory limit can be configured in following places:

  1. php.ini
  2. .htaccess file
  3. php scripts
1

set to 2048M - still getting the Error:

PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

Why in the hell does this thing eat up so much damn memory?

  • even cranked it up to 8192M - same result. – Scott Nov 14 '17 at 17:51
0

This might be due lack of server resources to run Magento. Here you can see a list of those, but in my opinion are pretty low.

0

I run into this issue after upgrading from magento 1.7.0.2 to 1.9.3.7.

After tracking the logs, there was nothing wrong in the client behavior. He just navigated a couple of categories and suddenly it started failing.

Even though all pages were running properly with 256M of memory limit, for this particular client it was failing. so following everybody's advice I kept increasing memory until 4gb, and it didn't work... so something else is wrong.

It seemed like 2 potential problems could be happening:

- an infinite loop - an extremely slow processing task

I tried lots of things since the magento, php and nginx logs weren't offering much information.

I found out that if you delete the client session from the DB or the var/sessions folder (depending on your implementation), the 500 error disappears. (though, it didn't explain if it was due to infinite loop or just slow processing).

In order to do that you can find the user's ip address in the server logs, and running a grep into the sessions folder or a query in the core_session table would take you to the client session.

As a potential ugly solution you could create a bash script that runs against the server logs looking for this error, find the session and delete it. Same thing you can achieve with loggly alerts, amazon CloudWatch. etc.

I kept investigating to answer to my question, and waited until the next client experienced the same issue, then I increased the max execution time to 6 minutes and memory to 6 gb with the hopes that finally magento would finish loading those requests (without running out of memory or execution time), and it worked. After finishing the request (taking several minutes) the 500 error disappeared for that client.

So it wasn't an infinite loop, it was a performance issue... even though it didn't seem so.

I implemented loggly and I'm waiting for it to happen again so I can activate the profiler immediately to find where the memory leak comes from. I'll update this answer if I'm successful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.