Do you know that there is a default memory limits in your PHP to refrain any programs from crashing? What you can do is to use a PHP infinite meaning all that is available, to be more exact in the amount of memory.  When we are in development production, we can see that our software uses more memory than we are expecting.Worry less because changing the RaM assigned in a single PHP script is easy. Find out below!


How to find Your php.ini?


Remember that there are two versions of php.ini on Linux. Why? Because there is a possibility that you will have a different version for command line scripts.



See the example below, in Ubuntu:


Command line: /etc/php5/cli/php.ini

Apache: /etc/php5/apache2/php.ini


While in a different version of Linux or BSD, it could be in different locations, but they are easy to find. Take note that on shared hosts, you may not have access to these files. But what you can do is to get in touch with your host, because they don't want anyone using all the RAM on the server


2. Edit Your “memory_limit”


Finding the php.ini file, you can open your favorite text editor by this command:


vim/nano/etc


With this line, you are editing the memory_limit. It can be similar to the following below:


memory_limit = 64M


In this example, it is set up to 64MB, you can change it to 128MB or 32MB. What you can do is to change this line, after setting the line, you can now save then exit your php.ini file.


If you want to change the web server's php.ini, you can restart the web server, How? you need to run the following:


sudo service apache2 restart


If you really think and happy to know what you are doing,  that is good because you are capable in setting the limit of your memory in using all the RAM available. What's troubling is if your script is out of control, there is a possibility that your machine will crash. It's not totally recommended, but it's an option for you.


To accomplish this just set the memory limit to -1 like this:


memory_limit = -1


Now that you've learn how it will work! It looks hard but it as simple as you can see, you just need to manipulate your php.ini file.