2 minutes reading time (486 words)

Are you getting your fair share of PHP memory?

Are you getting your fair share of PHP memory?

I remember when 4K of RAM was considered alot of memory. Granted, this was quite some time ago and things have certainly progressed since then. Today it seems like every other year adds a Giga-byte or two of RAM to the default configuration of our personal workstation. Well, a similar trend is evident with online memory in shared PHP environments.

Evolution

As Joomla and its extensions evolve, it seems like shared host environments need more PHP memory to support Joomla powered websites. My experience has shown that 48M of PHP memory is the recommended amount needed for typical websites and in many cases this figure could by bumped up to more than 64M.

Sometimes your php.ini file says one thing, but reality demonstrates something different. What can you do when your hosting company comes back to you with a reply like: "your php.ini memory limit is set to 128M" even though you have seen the dreadful "Fatal error: Allowed memory size of XXXXXXX bytes exhausted..." when trying to load your website page. Well, read on to see how you can debug things on your own, and how to use your findings to reply to your hosting company's support team. First of all, you should know that when you get an error message like:

Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 71 bytes)

it typically means that you are not able to allocate more than 24M (this is 1024 x 1024 x 24 = 25165824) bytes worth of memory — no mater what your hoster tells you, or what your php.ini files states, or what your Joomla System info php information tab states.

First thing you should check is your PHP Information tab of your Joomla System Info menu as illustrated in the following two figures:

phpmem-1

phpmem-2

From these two figures it looks like the PHP memory in this Joomla! website environment is set to 64M. But how can we verify this?

I have coded a simple php script to brute force test memory allocations. Just download the following script and upload it to your hosting environment. If you upload it to your html public folder then execute it by accessing the URL http://www.yourdomain.com/phpmemtest.php — you should see some output like the following figure.

phpmemrun

So, according to this script, it looks like only 48M are available in this environment and something is prohibiting our script to reach the 64M allocation limit that the PHP Information tab is claiming. This information — the script and its output — should be sufficient to present to your host support team to document your claim.

Having responded to many forum requests on Joomlapolis regarding exhausted memory we have created a FAQ article describing basic steps to debug such situations. This FAQ article can be read here. Notice how the community has responded and contributed the Apache setting.

Hopefully, this article will help those confronted with memory issues.

0
12 Usability Guidelines Every Joomla! Template Sho...
 

Comments

Already Registered? Login Here
No comments made yet. Be the first to submit a comment

By accepting you will be accessing a service provided by a third-party external to https://magazine.joomla.org/