I am getting the following error when clicking on a category named Test
FastCGI sent in stderr:
PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 32 bytes) in /home/mydomain/public_html/app/functions/fn.catalog.php on line 736" while reading response header from upstream, client: 24.xx.xx.xx, server: www.mydomain.com, request: "GET /test-page-313/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.mydomain.com", referrer: "http://www.mydomain....lesale-towels/"
My 736 Line is as follows
In my php.ini
I've already increase the memory_limit
to = 1G
for ($qty = $min_qty; $qty <= $max_qty; $qty += $product['qty_step']) {
$qty_content[] = $qty;
}
Several possibilities :
$product['qty_step']
doesn't contain a number$qty_content
array.For example, if you have:
$min_qty = 0;
$max_qty = 400000;
$product = array("qty_step" => 0.001);
$qty_content = [];
// The loop
for ($qty = $min_qty; $qty <= $max_qty; $qty += $product['qty_step']) {
$qty_content[] = $qty;
}
The program will try to make up to 400000000 entries in the array, which takes so much memory that PHP can't handle it. So it throws the error you've got. As someones said in your question's comments, try to debug the content of all variables, for example:
var_dump(
array('qty' => $qty,
'min_qty' => $min_qty,
'max_qty' => $max_qty,
'product["qty_step"]' => $product['qty_step'])
);
And see what you get. In all cases, this error means you're taking too much memory, so you must reduce the loop's iterations by increasing $product['qty_step']
or reducing the difference between $min_qty
and $max_qty
.