Upper memory limit for PHP/Apache

前端 未结 9 1100
没有蜡笔的小新
没有蜡笔的小新 2020-12-01 16:23

I\'m getting the error when I run my PHP script....

Fatal error: Out of memory (allocated 1827405824) (tried to allocate 88800 bytes)

I\'ve

9条回答
  •  佛祖请我去吃肉
    2020-12-01 16:41

    Check your Apache config (e.g., httpd.conf). There's likely an RLimitMEM directive limiting the memory allow for children processes handling requests.

    So, you can set your PHP limit all you want, if Apache spawns the process with a memory limit, you can't exceed that.

    If you're on a hosted service and have a shared server, likely you don't have access to this config and need to work with your provider. As you can see, it's configuration that applies server-wide... you're not likely going to get them to change this. Then again, if you're looking to spawn bigger than 1.5Gig processes, you prolly should be either solving the problem a different way (others have suggested this) or getting a dedicated server of some kind (e.g. EC2).

    For example:

    /usr/local/apache/conf
    #RLimitMEM 85643200 104857600   # Limit to: 80Mb / process, 100Mb total
    RLimitMEM 134217728 537395200   # Limit to: 128Mb / Process, 512Mb total
    

提交回复
热议问题