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

前端 未结 29 2476
天涯浪人
天涯浪人 2020-11-21 22:57

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 repor

相关标签:
29条回答
  • 2020-11-21 23:41

    I find it useful when including or requiring _dbconnection.php_ and _functions.php in files that are actually processed, rather than including in the header. Which is included in itself.

    So if your header and footer is included, simply include all your functional files before the header is included.

    0 讨论(0)
  • 2020-11-21 23:42

    The memory allocation for PHP can be adjusted permanently, or temporarily.

    Permanently

    You can permanently change the PHP memory allocation two ways.

    If you have access to your php.ini file, you can edit the value for memory_limit to your desire value.

    If you do not have access to your php.ini file (and your webhost allows it), you can override the memory allocation through your .htaccess file. Add php_value memory_limit 128M (or whatever your desired allocation is).

    Temporary

    You can adjust the memory allocation on the fly from within a PHP file. You simply have the code ini_set('memory_limit', '128M'); (or whatever your desired allocation is). You can remove the memory limit (although machine or instance limits may still apply) by setting the value to "-1".

    0 讨论(0)
  • 2020-11-21 23:42

    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
    

    0 讨论(0)
  • 2020-11-21 23:42

    In Drupal 7, you can modify the memory limit in the settings.php file located in your sites/default folder. Around line 260, you'll see this:

    ini_set('memory_limit', '128M');
    

    Even if your php.ini settings are high enough, you won't be able to consume more than 128 MB if this isn't set in your Drupal settings.php file.

    0 讨论(0)
  • 2020-11-21 23:42

    change ;memory_limit=512M to ;memory_limit=-1 in

    it's too dangerous for a server Your PHP code may have a memory leak somewhere and you are telling the server to just use all the memory that it wants. You wouldn't have fixed the problem at all. If you monitor your server, you will see that it is now probably using up most of the RAM and even swapping to disk.

    0 讨论(0)
  • 2020-11-21 23:43

    Using yield might be a solution as well. See Generator syntax.

    Instead of changing the PHP.ini file for a bigger memory storage, sometimes implementing a yield inside a loop might fix the issue. What yield does is instead of dumping all the data at once, it reads it one by one, saving a lot of memory usage.

    0 讨论(0)
提交回复
热议问题