


Sharing the method of modifying PHP's memory_limit limit_PHP tutorial
To solve this problem, you first need to check whether your program has allocated too much memory. If there are no problems with the program, you can increase PHP's memory limit (memory_limit) through the following methods.
Check the memory limit value of php
In order to view this value, you need to create an empty php file, such as view-php-info.php. Then paste the code inside.
Put this script on your web server and call it in your browser. At this time you can see the information about your PHP environment configuration, part of which is about "memory_limit", as shown below:
Note: You can use this method to view other parameter settings of php, not just memory_limit
What should the memory_limit be set to?
This completely depends on the requirements of your application. For example, WordPress requires 32MB to run the core code. Drupal 6 requires this value to be at least 16MB, and recommends setting it to 32MB. If you install a lot of plug-ins, especially those that require image processing, you may need 128MB or more memory.
How to set memory_limit
Method 1: php.ini
The simplest or most common method is to modify php.ini
1. First find the php.ini file that is effective for your website. Since there are multiple places where you can set php parameters, finding the correct configuration file and making changes is the first step. If you created a php file using the above method to view its configuration parameters, you can find the "Loaded Configuration File" item. The following is an example:
For Linux users, you can find the corresponding configuration file by executing "php -i | grep Loaded Configuration File". For Windows users, you can try modifying php.ini in your php installation directory.
2. Edit php.ini In php.ini, find the "memory_limit" item. If not, you can add this parameter yourself at the end of the file. Here are some setup examples
memory_limit = 128M; You can change 128M to any value you want to set
Save file
3. Restart the web server. If the web server uses Apache, execute:
httpd restart
In some cases, you may not be allowed to modify php.ini privately. For example, if you purchased a virtual hosting service, but your service provider does not allow you to modify this file. Then, you may want to consider other methods to increase the value of memory_limit.
Method 2: .htaccess
Note: This method only takes effect when php is executed with the Apache module. Find the ".htaccess" file in the root directory of your website. If you don't have one, you can create one yourself. Then put the following configuration into it
php_value memory_limit 128M; You can change 128M to any value you want to set
Method 3: Modify PHP’s memory settings at runtime
Just add the following command line to your php code.
ini_set('memory_limit','128M');
Memory_limit modification failed
If you use a virtual host, there may be a failure to modify the value of memory_limit. You need to contact your service provider to see how to deal with this. Usually they limit the maximum value that can be set or do not allow you to modify it at all. If their environment really cannot meet your requirements, then you may want to consider changing to another hosting provider.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.
