"how to get the real memory limit in a php script?" Code Answer

2

ini_set returns the old value on success, or false on failure. so you might want to check it:

if (ini_set('memory_limit', 'somethinginsanelyhigh') === false) {
  // cannot set memory_limit
}

also, take into account that this will set the maximum amount of memory that the current php process will take, so if you are going to have multiple concurrent requests to this script, you will want to have something reasonable, in case your script really eats so much memory.

also setting it to -1 means no memory limit.

edited: disabling memory limit is setting the value to -1, not setting it to 0.

By romanoza on July 26 2022

Answers related to “how to get the real memory limit in a php script?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.