October 24, 2020


Thinking Magento

Fatal error: Allowed memory size of XXXX bytes exhausted - Sales_Order_Collection Grid

Are you suddenly receiving the error Fatal error: Allowed memory size of XXXX bytes exhausted when viewing a grid in the magento admin, which uses sales order collection data?

Symptons: The admin grid loads correctly, however the footer does not appear to load. Right click on the page and go to view source, scroll down to the base of the source code page where the code ends you should see the Fatal Error:

The problem could be much easier than you could ever hope and caused by Mass Action and the Select All option.

When select all is enabled on an admin grid, it appears top left of the grid, next to select visible and it pre populates the javascript mass action with ALL of the row ID's and can be quite a memory strain on your server.

Find the grid.php file that is causing you problems (It may not be called grid.php if it is in a custom module) and locate the _prepareMassaction() function

In _prepareMassaction() you will need to add the following code to disable the select all button and save on server resources.


So your code could look something like this


If this saved you hours of work or saved you from a headache, feel free to buy us a beer.