The memory_limit directive in PHP controls the maximum amount of memory a script can allocate. By default, this value is set to 128 MB. On ruachost.com, you can increase or decrease this limit depending on your application’s requirements.

 

Why Change the Memory Limit?

  • Prevents “Allowed memory size exhausted” errors when running large scripts.

  • Supports applications that process big files, images, or complex database queries.

  • Helps optimize performance by balancing memory usage and server stability.

 

Methods to Change memory_limit

1. Using a Custom php.ini File

Create or edit a php.ini file in your application directory:

memory_limit = 256M

This sets the maximum memory allocation to 256 MB.

 

2. Using .user.ini

If your hosting environment supports .user.ini, add:

memory_limit = 256M
 

3. Using .htaccess

On Apache servers, you can override the directive:

 
php_value memory_limit 256M

4. Using cPanel (CageFS Enabled Accounts)

  1. Log in to cPanel.

  2. Go to Software → Select PHP Version → Options tab.

  3. Locate memory_limit.

  4. Set the desired value (e.g., 256M, 512M).

  5. Save changes.

 

Best Practices

  • Increase gradually (e.g., 256M → 512M) instead of setting excessively high values.

  • Avoid setting unlimited memory (-1) unless absolutely necessary, as it can destabilize the server.

  • Monitor application performance after changes to ensure stability.

Je li Vam ovaj odgovor pomogao? 0 Korisnici koji smatraju članak korisnim (0 Glasovi)

Powered by WHMCompleteSolution