Jump to content

[solved]Fatal error: Allowed memory size of...... bytes exhausted .... Search.php


Recommended Posts

Hi, I was not sure about to open a new post. Tried find out the answers but no one has the same problem as me. I ask you anyway cause. The fact, most of the people solve the problem increasing the memory_limit. I already set it to 512M, and the problem still there. Some differences with others are i have around 12,000 categories where 5,000 products are into them. MySQL table _category_product shows 885,000 combinations. Can you guide me to solve the problem? The site is working properly but when I make a search, whatever, using the search block shows the blank page with the Fatal Error message. I re-indexed but nothing changes.

Many Thanks in advance.

Edited by El Patron (see edit history)
Link to comment
Share on other sites

First, Thanks all of you.

 

 

ps version?

 

The latest: 1.5.6

 

Can you also complete the .... with the actual numbers.

 

Sorry, I don't know what you mean.

 

More memory. I have seen a shop where at least 2GB for PHP is enough. Of course, it contains many many categories and products.

 

I can do it, but, is it all about memory? I'll check and let you know.

Link to comment
Share on other sites

I can do it, but, is it all about memory? I'll check and let you know.

The best approach is to have a local development environment with all data. Then you can see all without needing to purchase larger hosting program.

 

I have seen how creating of search index took almost 2GB (PrestaShop v1.4). Indexing is not so clever and memory is realy wasted in PrestaShop.

  • Like 1
Link to comment
Share on other sites

I really appreciate your help. Problem wasl solved increasing the memory limit to 2GB

 

 

Wajalot: I mean what were the actual numbers you saw, instead of ....

 

More than 512M as you can read above... :mellow: and less to 2GB ;)

 

did you turn on errors to see what the 'blank' page was having a problem with....it may not be memory at all...

 

try this and post (search as well) on the error

 

http://www.prestashop.com/forums/topic/224525-how-to-turn-on-error-reporting-for-debug-information-500-error-or-blank-page/

 

Yes, I did and the title of the post is part of the error message. Anyway, even increasing the memory_limit to 2GB there must be something not so good with the php code in prestashop.

 

The best approach is to have a local development environment with all data. Then you can see all without needing to purchase larger hosting program.

 

I have seen how creating of search index took almost 2GB (PrestaShop v1.4). Indexing is not so clever and memory is realy wasted in PrestaShop.

 

 

Well. You gave me the answer: 2GB. It's really a big amount of memory.  I checked with 1 GB and the problem still there. Going up to 2GB searching works fine. Even faster than I expected, it takes around 5 seconds. I know it's bit long time, but usually customers know we have more than 5.000 products into a 13.000 categories.A point to consider in next versions is prestashop wastes, as you notice above, a lot of memory and php code or database indexing is not so good as you could expect. I think is more a problem of indexing. In fact the "_category_product" table should be improved.

 

Anyway, thanks a lot for your help to all of you. :) :) :) :) :P

 

 

PD: Mods can edit the title with [solved]....

Edited by Wajalot (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hi. I had a similar problem and found some solutions (other than increasing the memory limit).

 

I'm using PrestaShop 1.5.6.1, default theme (with several modules uninstalled, and only one language installed). My shop has about 29000 products and 200 categories. My PHP memory_limit is 90M. This error appears when I perform any search on the front end:

 

Fatal error: Out of memory (allocated 47 448 064) (tried to allocate 524 288 bytes) in classes/Search.php on line 256.

 

Solution 1

 

On line 238 of classes/Search.php, replace this:

$sql = 'SELECT cp.`id_product`

with this:

$sql = 'SELECT DISTINCT cp.`id_product`

.

Solution 2

 

On line 251 of the same file, replace this:

)');

with this:

)') . ' AND cp.`id_product` IN (' . $intersect_array[0] . ')';

The problem lies between lines 238 and 251, where a query is defined to select all the products which should be visible to the user, given his permissions, and regardless of the entered search terms. This is the full query:

        $sql = 'SELECT cp.`id_product`
                FROM `'._DB_PREFIX_.'category_group` cg
                INNER JOIN `'._DB_PREFIX_.'category_product` cp ON cp.`id_category` = cg.`id_category`
                INNER JOIN `'._DB_PREFIX_.'category` c ON cp.`id_category` = c.`id_category`
                INNER JOIN `'._DB_PREFIX_.'product` p ON cp.`id_product` = p.`id_product`
                '.Shop::addSqlAssociation('product', 'p', false).'
                WHERE c.`active` = 1
                    AND product_shop.`active` = 1
                    AND product_shop.`visibility` IN ("both", "search")
                    AND product_shop.indexed = 1
                    AND cg.`id_group` '.(!$id_customer ?  '= '.(int)Configuration::get('PS_UNIDENTIFIED_GROUP') : 'IN (
                        SELECT id_group FROM '._DB_PREFIX_.'customer_group
                        WHERE id_customer = '.(int)$id_customer.'
                    )');

Both of the previous solutions worked for me, but I don't know which one is better. More experienced users could tell.

 

I hope this is useful for someone else. Best wishes.

  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...