
Please note that depending of your Cpanel configuration things may look different or this option might not even exist. There you will find a selector for PHP memorylimit. On the next screen, press ‘Switch to PHP options’.
#Php free memory code#
I’ve found sometimes I need to edit the php.ini file and sometimes put the code into the. Log in into your Cpanel account, and find the ‘Select PHP Version’ menu. Also, some hosting providers will ignore your attempts to modify the memory limits for your PHP code so you might need to contact your hosting support to assist you. Try disabling modules one by one to identify which is bringing the party down. For example, in Drupal, the admin/modules page loads every module in your Drupal installation, which can get hairy if a custom module is buggy, corrupt or hacked. The Eclipse Memory Analyzer is a fast and feature-rich Java heap analyzer that helps you find memory leaks and reduce memory consumption. If you’re getting this error message in Drupal or Joomla, the likely culprit is a new module or package.

Simply echo it at any point in your script to find out where your memory usage is spiking: One way to figure out how much memory your PHP script is using is to use the memory_get_usage() PHP function.

What you should really be doing is trying to figure out why your script is using so much memory and attempt to fix it. Really, your PHP script should not be exceeding 8 MB, unless your uploading files or doing something else that’s obviously taking up a lot of memory usage. Now, remember, this is only a workaround. Note: You can also use the memory_limit line in your. This isn’t usually a good idea, though, for obvious reasons. Note: This function used to be called pgfreeresult (). Otherwise, all result memory will be automatically freed when the script ends. This function need only be called if memory consumption during script execution is a problem. You can also disable the memory limit by setting memory_limit to –1 in PHP.ini. pgfreeresult () frees the memory and data associated with the specified PgSqlResult instance.

Apparently, the memory_limit default was upped from 8M to 16M in PHP 5.2.0 and is now 128M for PHP 5.3.0, which would explain why you may not get this error message at all. But it has the same workaround as “Fatal error: Allowed memory size of 8388608 bytes exhausted…” or “Fatal error: Allowed memory size of 16777216 bytes exhausted…” or whatever. So, if I were to ever receive this error message it would read: “Fatal error: Allowed memory size of 134217728 bytes exhausted…” and obviously be a much bigger problem. I’ve noticed in my own PHP.ini file that my default is much higher at 128M. Simply open php.ini and find the line that reads “memory_limit” and alter it: This will affect all scripts on your server. This will only alter the memory limit for that particular PHP file.Īlternately, you can alter your php.ini file to up the memory limit. You can, and should, fiddle with this number so that it is as low as possible without repeating that error message. This will set your memory limit to 16 MB, rather than 8 MB.
