2.8.7. memory_limit

Parameter memory_limit sets the maximum amount of memory that site scripts can use. It helps to prevent situations when poorly written scripts consume all available server memory.

Installed for memory_limit the amount of memory is allocated for each running script separately, so the simultaneous launch of several scripts cannot consume all the allocated memory_limit, but can consume the entire RAM of the hosting account (can be seen at charts consumption of server resources). It is important to understand that when running the script, the amount of memory allocated under the memory limit_limit, not "pickedup" from RAM. Memory is allocated gradually as it is consumed by each script, but cannot exceed the specified limit, therefore the opinion that by running two scripts with the value of memory_A limit of 1024 MB will be used immediately by 2048 MB, which is fundamentally wrong.

Determine in advance how much memory or what memory limit_limit is required by a site or a script, it is almost impossible, since it all depends on the quality of the scripts themselves and the amount of data they process.

If the site scripts exceed the available memory space, an error may occur "Fatal error: Allowed memory size of XXX bytes exhausted (tried to allocate YYY bytes)"... A description and options for its solution can be found in here.
  • Does not affect the speed of the scripts.
  • The maximum value depends on the used tariff:
    • On a regular hosting: from 512 to 1536 MB.
    • On businesshosting — within the limits of the amount of RAM available at the tariff.
  • For console and cron the default value is 512 MB. It can be equated to the value of one of the sites, if when you run the script connect site ini file.
Memory value_limit in PHP settings site does not affect the default in console and cron... To run the script with a console command with the parameter value as on the site, use instruction.
  1. Open the section "PHP settings" the site for which you want to change the parameter value.
  2. Specify the desired value opposite "php_memory_limit" and at the bottom of the page click "Save":
    • Available values - from 1 MB to the maximum available in the current tariff.
    • If you specify 0, after saving the value will be equal to the maximum available in the current tariff.
  3. Wait approximately 10-15 minutes for the changes to take effect.

Attention!

Purchase of additional services Memcache(d), Redis or OPcache does not increase memory value_limit.

On an ongoing basis:

  • By transition the tariff is higher.
  • By changes memory values_limit in PHP settings site, if the size of the error is indicated in the text of the error smaller available at the current rate.
Content