0

I got a php error randomly, Allowed memory size of 2147483648 bytes exhauste and customers see the 500 Internal Server Error. It happens most often after importing products with Dataflow, when customers want to add a product to the basket or finalize the order. Below the details of the error. I need help in determining what cause the error.

Array([0] => SELECT `main_table`.* FROM `sales_flat_quote_address_item` AS `main_table` WHERE (`quote_address_id` = '59764')
[1] => Array
    (
        [shipping_method] => tablerate_bestway
        [form_key] => msbjhd
    )
[2] => Array
    (

        [SCRIPT_NAME] => /index.php
        [REQUEST_URI] => /checkout/onepage/saveShippingMethod/
        [QUERY_STRING] => 
        [REQUEST_METHOD] => POST
        [SERVER_PROTOCOL] => HTTP/1.1
        [GATEWAY_INTERFACE] => CGI/1.1
        [REDIRECT_URL] => /checkout/onepage/saveShippingMethod/
        [REMOTE_PORT] => 33215
        [SERVER_SOFTWARE] => Apache/2.4.10 (Debian)

        [HTTP_ACCEPT_ENCODING] => gzip, deflate, br
        [HTTP_REFERER] => https://xxx/checkout/onepage/
        [CONTENT_TYPE] => application/x-www-form-urlencoded; charset=UTF-8
        [HTTP_USER_AGENT] => Mozilla/5.0 (Linux; Android 7.0; SM-G920F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.80 Mobile Safari/537.36
        [HTTP_X_REQUESTED_WITH] => XMLHttpRequest

        [HTTP_X_PROTOTYPE_VERSION] => 1.7
        [HTTP_ACCEPT] => text/javascript, text/html, application/xml, text/xml, */*
        [CONTENT_LENGTH] => 59
        [HTTP_CONNECTION] => keep-alive

        [SSL_SESSION_RESUMED] => Resumed

        [REDIRECT_HTTP_AUTHORIZATION] => 
        [FCGI_ROLE] => RESPONDER
        [PHP_SELF] => /index.php
        [REQUEST_TIME_FLOAT] => 1542663024.8916
        [REQUEST_TIME] => 1542663024
    )
[3] => Array
    (
        [type] => 1
        [message] => Allowed memory size of 2147483648 bytes exhausted (tried to allocate 16384 bytes)
        [file] => .../lib/Zend/Db/Statement/Pdo.php
        [line] => 232
    ))

Second code

Array([0] => SELECT `main_table`.*, `cp_table`.`type_id`, `status_table`.`stock_status` FROM `cataloginventory_stock_item` AS `main_table`
 INNER JOIN `catalog_product_entity` AS `cp_table` ON main_table.product_id = cp_table.entity_id
 LEFT JOIN `cataloginventory_stock_status` AS `status_table` ON main_table.product_id=status_table.product_id AND main_table.stock_id=status_table.stock_id AND status_table.website_id='1' WHERE (`main_table`.`stock_id` = '1') AND (`main_table`.`product_id` IN('141061'))
    [1] => Array
        (
            [form_key] => msbjhd
            [product] => 141061
            [related_product] => 
            [options] => Array
                (
                    [164742] => 1839646
                    [164740] => 1839643
                    [164741] => 1839645
                    [164739] => 1839641
                )

            [qty] => 6
            [isAjax] => 1
        )
    [2] => Array
        (
            [SCRIPT_NAME] => /index.php
            [REQUEST_URI] => /checkout/cart/add/uenc/adfbjhdgbfdjhgbdjghbjYS5wbC9rb2xla2NqZS1kZWJvd2Uva3J6ZXNsYS1kZWJvd2Uva3J6ZXNsby1kZWJvd2UtMDJjLmh0bWw=/product/141061/form_key/msbjhd/
            [QUERY_STRING] => 
            [REQUEST_METHOD] => POST
            [SERVER_PROTOCOL] => HTTP/1.1
            [GATEWAY_INTERFACE] => CGI/1.1
            [REDIRECT_URL] => /checkout/cart/add/uenc/adfbjhdgbfdjhgbdjghbjYS5wbC9rb2xla2NqZS1kZWJvd2Uva3J6ZXNsYS1kZWJvd2Uva3J6ZXNsby1kZWJvd2UtMDJjLmh0bWw=/product/141061/form_key/msbjhd/
            [REMOTE_PORT] => 50221
            [SERVER_SOFTWARE] => Apache/2.4.10 (Debian)

            [FCGI_ROLE] => RESPONDER
            [PHP_SELF] => /index.php
            [REQUEST_TIME_FLOAT] => 1542966054.1767
            [REQUEST_TIME] => 1542966054
        )
    [3] => Array
        (
            [type] => 1
            [message] => Allowed memory size of 2147483648 bytes exhausted (tried to allocate 16384 bytes)
            [file] => ...lib/Zend/Db/Statement/Pdo.php
            [line] => 232
        ))
0

You can have the memory limit updated on server in case its dedicated server. Otherwise you can add below code in your root index.php file:

ini_set('memory_limit','64M');
  • The error appears even if the limit is set to 8GB. – guest Nov 23 '18 at 12:06
  • Oh I see, it seems like it is not affecting the server memory_limit, you can check the same by running phpinfo.php for current memory limit. Follow below steps to create phpinfo file mediatemple.net/community/products/dv/204643880/… You have to update memory limit on server in that case – Himmat Paliwal Nov 23 '18 at 12:47
  • The problem is more complicated. Setting the limit on the server works correctly. In the above log you can see that the limit was set to 2GB. The error appears even at the limit of 8GB. In the above log you can see at which operation the error occurred, but I need help in determining why. Thank You. – guest Nov 23 '18 at 13:41
  • Ok give a try to ini_set('memory_limit', -1); and also please note that memory limitation comes from the OS too, not from PHP only. It may be an issue with 32 bit os, try with 64 bit os in case. – Himmat Paliwal Nov 24 '18 at 5:22

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.