Forums / General Questions / PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

Views: 10,161

Results 1 to 13 of 13
15 Mar 2014, 6:41 AM
#1
jwaynehinkle avatar

jwaynehinkle

New Zenner

Join Date:
Aug 2013
Location:
United States
Posts:
73
Plugin Contributions:
0

PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

So I am going through my logs and I have for the most part got them all cleaned up however there are a few that are absolutely blowing my mind and I can not put my finger on

PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 36 bytes) in includes/classes/db/mysql/query_factory.php on line 486
this line contains

while (list($key, $value) = each($zp_result_array)) {

and then in a different log there is this

PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 20 bytes) in /includes/classes/db/mysql/query_factory.php on line 487

this line contains ```php
if (!preg_match('/^[0-9]/', $key)) {


The entire section of code reads

```php
  function MoveNext() {
    global $zc_cache;
    $this->cursor++;
    if ($this->is_cached) {
      if ($this->cursor >= sizeof($this->result)) {
        $this->EOF = true;
      } else {
        while(list($key, $value) = each($this->result[$this->cursor])) {
          $this->fields[$key] = $value;
        }
      }
    } else {
      $zp_result_array = @mysql_fetch_array($this->resource);
      if (!$zp_result_array) {
        $this->EOF = true;
      } else {
        while (list($key, $value) = each($zp_result_array)) {
          if (!preg_match('/^[0-9]/', $key)) {
            $this->fields[$key] = $value;
          }
        }
      }
    }
  }

and then there is this one

PHP Warning: Illegal string offset 'cost' in /includes/classes/order.php on line 384

this line is

'shipping_cost' => $_SESSION['shipping']['cost'],

the entire section of code is

$this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID,
                        'currency' => $_SESSION['currency'],
                        'currency_value' => $currencies->currencies[$_SESSION['currency']]['value'],
                        'payment_method' => $GLOBALS[$class]->title,
                        'payment_module_code' => $GLOBALS[$class]->code,
                        'coupon_code' => $coupon_code->fields['coupon_code'],
    //                          'cc_type' => (isset($GLOBALS['cc_type']) ? $GLOBALS['cc_type'] : ''),
    //                          'cc_owner' => (isset($GLOBALS['cc_owner']) ? $GLOBALS['cc_owner'] : ''),
    //                          'cc_number' => (isset($GLOBALS['cc_number']) ? $GLOBALS['cc_number'] : ''),
    //                          'cc_expires' => (isset($GLOBALS['cc_expires']) ? $GLOBALS['cc_expires'] : ''),
    //                          'cc_cvv' => (isset($GLOBALS['cc_cvv']) ? $GLOBALS['cc_cvv'] : ''),
                        'shipping_method' => (is_array($_SESSION['shipping']) ? $_SESSION['shipping']['title'] : $_SESSION['shipping']),
                        'shipping_module_code' => (isset($_SESSION['shipping']['id']) && strpos($_SESSION['shipping']['id'], '_') > 0 ? $_SESSION['shipping']['id'] : $_SESSION['shipping']),
                        'shipping_cost' => $_SESSION['shipping']['cost'],
                        'subtotal' => 0,
                        'shipping_tax' => 0,
                        'tax' => 0,
                        'total' => 0,
                        'tax_groups' => array(),
                        'comments' => (isset($_SESSION['comments']) ? $_SESSION['comments'] : ''),
                        'ip_address' => $_SESSION['customers_ip_address'] . ' - ' . $_SERVER['REMOTE_ADDR']
                        );

Then here is another one

PHP Warning: Creating default object from empty value in /includes/modules/shipping_estimator.php on line 92

this line contains

$order->delivery = array('postcode' => $zip_code,

then in a different log there is this one

PHP Warning: Creating default object from empty value in /includes/modules/shipping_estimator.php on line 117

this line contains

$country_info = $_SESSION['country_info'];

this entire section is

// user not logged in !
    if (isset($_POST['zone_country_id'])){
      // country is selected
      $_SESSION['country_info'] = zen_get_countries($_POST['zone_country_id'],true);
      $country_info = $_SESSION['country_info'];
      $order->delivery = array('postcode' => $zip_code,
                               'country' => array('id' => $_POST['zone_country_id'], 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' =>  $country_info['countries_iso_code_3']),
                               'country_id' => $_POST['zone_country_id'],
                               //add state zone_id
                               'zone_id' => $state_zone_id,
                               'format_id' => zen_get_address_format_id($_POST['zone_country_id']));
      $_SESSION['cart_country_id'] = $_POST['zone_country_id'];
      //add state zone_id
      $_SESSION['cart_zone'] = $state_zone_id;
      $_SESSION['cart_zip_code'] = $zip_code;
    } elseif ($_SESSION['cart_country_id']){
      // session is available
      $_SESSION['country_info'] = zen_get_countries($_SESSION['cart_country_id'],true);
      $country_info = $_SESSION['country_info'];
      // fix here - check for error on $cart_country_id
      $order->delivery = array('postcode' => $_SESSION['cart_zip_code'],
                               'country' => array('id' => $_SESSION['cart_country_id'], 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' =>  $country_info['countries_iso_code_3']),
                               'country_id' => $_SESSION['cart_country_id'],
                               'zone_id' => $state_zone_id,
                               'format_id' => zen_get_address_format_id($_SESSION['cart_country_id']));
    } else {
      // first timer
      $_SESSION['cart_country_id'] = STORE_COUNTRY;
      $_SESSION['country_info'] = zen_get_countries(STORE_COUNTRY,true);
      $country_info = $_SESSION['country_info'];
      $order->delivery = array(//'postcode' => '',
                               'country' => array('id' => STORE_COUNTRY, 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' =>  $country_info['countries_iso_code_3']),
                               'country_id' => STORE_COUNTRY,
                               'zone_id' => $state_zone_id,
                               'format_id' => zen_get_address_format_id($_POST['zone_country_id']));
    }

Any help would be greatly appreciated.

Thanks in advanced fellow Zenners!

15 Mar 2014, 1:58 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

Glad that you are investigating issues inside the cart. First question is, have you updated your error reporting so that it reports the real line number and not the one above where the error occurred? It would be my guess based on the second error where only a comparison is performed and not an assignment like the first error that that update has not been applied. Neither here nor there.

A few other things, it would help some more also if more of the zC posting guidelines were followed. (Version#, etc.)

Address the errors first, and perhaps the warnings will go away. What other plugin(s) are installed? Might they relate to the warnings? Ie, are they up-to-date?

Typically query_factory is just processing what it has been given. I think lat9 developed some mods to it to identify the source of the query causing a problem, although I don't know if it would cover an out of memory condition. There is a few threads begun about running out of memory especially when the pHP version has recently been updated. The fix for one individual was basically to rebuild three databases by in essence reinstalling ZC or at least rebuilding the database from commands rather than copying files.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

15 Mar 2014, 2:04 PM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

mc12345678:

... I think lat9 developed some mods to it to identify the source of the query causing a problem, although I don't know if it would cover an out of memory condition. ...
Not a mod, but a suggestion: http://www.zen-cart.com/showthread.php?211396-Use-debug_backtrace%28%29-to-determine-query_factory-caller-on-error

As mc12345678 indicated, knowing the information that's requested in the Posting Tips would take a lot of the guessing out of the game.

16 Mar 2014, 6:02 AM
#4
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

Hmmm, do you really have PHP configured with only 32M of memory? Have to echo the "please answer the posting tips"... Especially what version of Zen Cart and PHP...

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

16 Mar 2014, 10:12 PM
#5
jwaynehinkle avatar

jwaynehinkle

New Zenner

Join Date:
Aug 2013
Location:
United States
Posts:
73
Plugin Contributions:
0

Re: PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

Currently I am running zen-cart 5.1, I believe it is all up to date as this was a fresh install less than 2 months ago and I made sure to download a new copy from the home page of this site and use it to complete the install. I am not sure if PHP is configured with only 32M of memory I would surely hope not, however that does not always mean anything I have come to find out, I will contact my host and see what the story is on that.

16 Mar 2014, 11:17 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

jwaynehinkle:

Currently I am running zen-cart 5.1, I believe it is all up to date as this was a fresh install less than 2 months ago and I made sure to download a new copy from the home page of this site and use it to complete the install. I am not sure if PHP is configured with only 32M of memory I would surely hope not, however that does not always mean anything I have come to find out, I will contact my host and see what the story is on that.

I thought I recalled something about memory size being in the php.ini file. Might be wrong.

Oh, yeah, and if it wasn't clear to anyone how that number was determined, look at the number that was almost exceeded and can tell, that, well: must be the limit. :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

17 Mar 2014, 12:33 AM
#7
jwaynehinkle avatar

jwaynehinkle

New Zenner

Join Date:
Aug 2013
Location:
United States
Posts:
73
Plugin Contributions:
0

Re: PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

Ok found out my host has the master value set at 32M, I do not have access to the php.ini file in the server root, however I was able to change the value with the local .htaccess file in my web root, now when I go to my phpinfo file that I made this is what it tells me the current value is

                    Local Value        Master Value

memory_limit 128M 32M

So now the question is will it use the master value or the local value?

17 Mar 2014, 11:50 AM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

lhungil:

Hmmm, do you really have PHP configured with only 32M of memory? Have to echo the "please answer the posting tips"... Especially what version of Zen Cart and PHP...
Nice spot, lhungil!

17 Mar 2014, 11:51 AM
#9
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

jwaynehinkle:

Ok found out my host has the master value set at 32M, I do not have access to the php.ini file in the server root, however I was able to change the value with the local .htaccess file in my web root, now when I go to my phpinfo file that I made this is what it tells me the current value is

                    Local Value        Master Value

memory_limit 128M 32M

So now the question is will it use the master value or the local value?
The local value will be used.

17 Mar 2014, 5:15 PM
#10
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

jwaynehinkle:

...
PHP Warning: Creating default object from empty value in /includes/modules/shipping_estimator.php on line 92
...
Still waiting for the OP to post what version of PHP they are using. The OP can find this by logging into the Zen Cart "administrative" interface and clicking "version". The page shown includes alot more information about which versions of various software are installed (Zen Cart, PHP, MySQL, etc).

Note: What are the server requirements to run Zen Cart?

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

17 Mar 2014, 5:31 PM
#11
jwaynehinkle avatar

jwaynehinkle

New Zenner

Join Date:
Aug 2013
Location:
United States
Posts:
73
Plugin Contributions:
0

Re: PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

HTTP Server: LiteSpeed V6.6
PHP Version: 5.4.25 (Zend: 2.4.0)
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with the ionCube PHP Loader v4.4.1, Copyright (c) 2002-2013, by ionCube Ltd., and
with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies
Database: MySQL 5.5.36-MariaDB
Database Data Size: 139,305 kB
Database Index Size: 33,779 kB

Is there anything wrong with my setup?

17 Mar 2014, 8:22 PM
#12
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

Nothing "wrong", but Zen Cart 1.5.0 / 1.5.1 was not designed for PHP 5.4, and thus is not fully compatible "out of box" with PHP 5.4. Some of the warnings you are seeing are probably related to attempting to run Zen Cart 1.5.1 under PHP 5.4.

The "warnings" will not stop your site from running, but may clutter / fill up your "log" folder. To avoid this you can see if the host will downgrade to PHP 5.3, or search the forums here for Zen Cart 1.5.1 PHP 5.4 patches...

The next release of Zen Cart (1.5.2) was designed to run on newer versions of PHP and is compatible with PHP 5.4. No set release date at this time (currently in PA-DSS assessment phase).

The glass is not half full. The glass is not half empty. The glass is simply too big!
Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

17 Mar 2014, 10:10 PM
#13
jwaynehinkle avatar

jwaynehinkle

New Zenner

Join Date:
Aug 2013
Location:
United States
Posts:
73
Plugin Contributions:
0

Re: PHP Fatal error: Allowed memory size of 32MB exhausted, in query_factory.php line 486

I did make sure that I installed the php5.4 updates, and since raising my memory limit I have not seen any of the memory related errors, now the only errors I seem to be getting are from, the Fedex shipping module so now to debug that, and then back to trying to figure out what on my site is using that much memory in PHP.....