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

前端 未结 29 2324
天涯浪人
天涯浪人 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:35

    PHP 5.3+ allows you to change the memory limit by placing a .user.ini file in the public_html folder. Simply create the above file and type the following line in it:

    memory_limit = 64M
    

    Some cPanel hosts only accept this method.

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

    I had the error below while running on a dataset smaller than had worked previously.

    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in C:\workspace\image_management.php on line 173

    As the search for the fault brought me here, I thought I'd mention that it's not always the technical solutions in previous answers, but something more simple. In my case it was Firefox. Before I ran the program it was already using 1,157 MB.

    It turns out that I'd been watching a 50 minute video a bit at a time over a period of days and that messed things up. It's the sort of fix that experts correct without even thinking about it, but for the likes of me it's worth bearing in mind.

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

    Change the memory limit in the php.ini file and restart Apache. After the restart, run the phpinfo(); function from any PHP file for a memory_limit change confirmation.

    memory_limit = -1
    

    Memory limit -1 means there is no memory limit set. It's now at the maximum.

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

    Your site's root directory:

    ini_set('memory_limit', '1024M');
    
    0 讨论(0)
  • 2020-11-21 23:40

    Crash page?

    (It happens when MySQL has to query large rows. By default, memory_limit is set to small, which was safer for the hardware.)

    You can check your system existing memory status, before increasing php.ini:

    # free -m
                 total       used       free     shared    buffers     cached
    Mem:         64457      63791        666          0       1118      18273
    -/+ buffers/cache:      44398      20058
    Swap:         1021          0       1021
    

    Here I have increased it as in the following and then do service httpd restart to fix the crash page issue.

    # grep memory_limit /etc/php.ini
    memory_limit = 512M
    
    0 讨论(0)
  • 2020-11-21 23:41

    The correct way is to edit your php.ini file. Edit memory_limit to your desire value.

    As from your question, 128M (which is the default limit) has been exceeded, so there is something seriously wrong with your code as it should not take that much.

    If you know why it takes that much and you want to allow it set memory_limit = 512M or higher and you should be good.

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