9

I was in some ubuntu server configs, and found that my memory on the server (online resources say default is usually 128Mb correct?)

and I found this listed

memory_limit = -1

Why? What does a value of -1 do? Php of 5.6

3 Answers 3

11

From the official documantation here:

This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. Note that to have no memory limit, set this directive to -1.

2
memory_limit = -1

Simply means to "have no memory limit" meaning: let the script use whatever is left over from the operating system and other important processes running. So if the machine has 4GIG and the OS + other processes use 2GIG, then your script will get the remaining 2GIG.

From the official docs and the important part is the last sentence!

memory_limit int

This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. Note that to have no memory limit, set this directive to -1.

By memory i mean "RAM & Virtual mem"

-1

Don't do that. Obviously php has a memory leak somewhere and you are telling the server to just use all the memory that it wants. The problem has not been fixed 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.

2
  • 6
    OP gives no indication in their question that there's a problem of any kind they're investigating - they could've just noticed it in the config and been curious. You're jumping to some unfounded conclusions.
    – ceejayoz
    Mar 29, 2017 at 18:43
  • Yes, is true. I did not have a problem and was curious. Although I agree with the proposed answer because he/she does make a point to monitor server if I did have a problem.
    – camdixon
    Mar 29, 2017 at 21:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .