QBoard » Big Data » Big Data - Data Processing and ETL » Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)

Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)

  • I have a bunch of client point of sale (POS) systems that periodically send new sales data to one centralized database, which stores the data into one big database for report generation.

    The client POS is based on PHPPOS, and I have implemented a module that uses the standard XML-RPC library to send sales data to the service. The server system is built on CodeIgniter, and uses the XML-RPC and XML-RPCS libraries for the webservice component. Whenever I send a lot of sales data (as little as 50 rows from the sales table, and individual rows from sales_items pertaining to each item within the sale) I get the following error:

    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 54 bytes)
    

     

    128M is the default value in php.in, but I assume that is a huge number to break. In fact, I have even tried setting this value to 1024M, and all it does is take a longer time to error out.

    As for steps I've taken, I've tried disabling all processing on the server-side, and have rigged it to return a canned response regardless of the input. However, I believe the problem lies in the actual sending of the data. I've even tried disabling the maximum script execution time for PHP, and it still errors out.

      December 9, 2021 1:06 PM IST
    0
  • When you see the above error - especially if the (tried to allocate __ bytes) is a low value, that could be an indicator of an infinite loop, like a function that calls itself with no way out:


    function exhaustYourBytes()
    {
        return exhaustYourBytes();
    }
      December 28, 2021 12:24 PM IST
    0
  • For Drupal users, this Chris Lane's answer of:

    ini_set('memory_limit', '-1');
    

     

    works but we need to put it just after the opening

    <?php
    

     

    tag in the index.php file in your site's root directory.

     
      January 7, 2022 12:33 PM IST
    0
  • After enabling these two lines, it started working:

    ; Determines the size of the realpath cache to be used by PHP. This value should
    ; be increased on systems where PHP opens many files to reflect the quantity of
    ; the file operations performed.
    ; http://php.net/realpath-cache-size
    realpath_cache_size = 16k
    
    ; Duration of time, in seconds for which to cache realpath information for a given
    ; file or directory. For systems with rarely changing files, consider increasing this
    ; value.
    ; http://php.net/realpath-cache-ttl
    realpath_cache_ttl = 120

     

    After enabling these two lines, it started working:

    ; Determines the size of the realpath cache to be used by PHP. This value should
    ; be increased on systems where PHP opens many files to reflect the quantity of
    ; the file operations performed.
    ; http://php.net/realpath-cache-size
    realpath_cache_size = 16k
    
    ; Duration of time, in seconds for which to cache realpath information for a given
    ; file or directory. For systems with rarely changing files, consider increasing this
    ; value.
    ; http://php.net/realpath-cache-ttl
    realpath_cache_ttl = 120
    

      December 14, 2021 11:42 AM IST
    0