Why Your Website is Hanging: Diagnosing PHP Memory Limits on Australian Shared Hosting
Summary
This guide helps you troubleshoot and resolve: Why Your Website is Hanging: Diagnosing PHP Memory Limits on Australian Shared Hosting. Follow the steps below to fix the issue.
Common Causes
Shared hosting environments allocate a specific amount of server memory to every website hosted on the same physical machine. When your website attempts to use more memory than your plan allows, the PHP process may terminate abruptly. This typically results in slow loading times, intermittent crashes, or "white screen of death" errors. For small businesses in Australia, this often happens as traffic grows or as plugins and scripts become more resource-intensive.
Most Australian shared hosting providers operate data centres in Sydney or Melbourne to reduce latency for local visitors. Support is generally provided during Australian Eastern Standard Time (AEST) or Australian Eastern Daylight Time (AEDT) business hours. Because resources are shared across multiple accounts on the same server, your host may enforce hard memory limits that cannot be overridden by your own configuration files.
Understanding PHP Memory vs Database Memory
It is important to distinguish between PHP memory and database memory. The PHP memory limit controls how much RAM a PHP script can use while executing code, such as loading a page or processing a form. Database memory refers to the RAM allocated to the database server (such as MySQL or MariaDB) for caching queries and table data. Exhausting the PHP limit produces errors like "Allowed memory size exhausted," while database pressure typically manifests as slow query responses or "Too many connections" errors. Both can cause your website to hang, but they require different remedies.
Diagnosing the Problem
1. Monitoring Resource Usage
Log in to your hosting control panel and navigate to the resource usage or statistics section. Look for spikes in memory consumption that correlate with the times your website hangs. If you notice consistent peaks hitting your limit, your site has likely outgrown its current shared hosting allocation.
2. Checking Your Current PHP Memory Limit
Before making changes, verify your current memory limit using one of the following methods:
WordPress Sites
- Log into your WordPress admin dashboard.
- Navigate to Tools > Site Health > Info.
- Expand the Server section and look for PHP memory limit.
Non-WordPress PHP Sites
- Create a new file named
info.phpin your website's root directory. - Add the following code to the file:
<?php phpinfo(); ?>
- Open the file in your browser (for example,
https://yourdomain.com.au/info.php). - Search the page for memory_limit to see the current value.
- Delete the
info.phpfile immediately after checking, as leaving it exposed is a security risk.
3. Checking Server Error Logs
Review your server error logs via your hosting control panel to confirm if PHP memory limit errors are being recorded. Look for messages such as "Allowed memory size exhausted" or "Fatal error: Out of memory". Note the time of the errors and compare them with traffic patterns or scheduled tasks.
4. Checking Cron Jobs and Background Processes
Scheduled tasks and background scripts can consume significant memory, especially if they run simultaneously with visitor traffic. In your hosting control panel, open the Cron Jobs or Scheduled Tasks section and review the following:
- The frequency of each scheduled job.
- Whether multiple jobs overlap at the same time.
- Any custom scripts that perform large imports, exports, or database backups.
If you identify a resource-heavy cron job, consider rescheduling it to off-peak hours or optimising the script to use less memory.
Increasing the PHP Memory Limit
wp-config.php, download a backup copy of the file to your local computer. If you make a syntax error, your website may become inaccessible until the file is restored.Method 1: Editing wp-config.php (WordPress)
If your website runs on WordPress, you can attempt to increase the memory limit by editing your configuration file.
- Access your files via FTP or the File Manager in your hosting control panel.
- Locate and open the
wp-config.phpfile in the root directory. - Add the following line of code before the line that says
/* That's all, stop editing! Happy publishing. */:
define( 'WP_MEMORY_LIMIT', '256M' );
- Save the file and refresh your website to see if the performance improves.
- Return to Tools > Site Health > Info > Server to verify that the PHP memory limit now reflects the new value.
Method 2: Using php.ini
Some shared hosting providers allow you to create or edit a php.ini file in your website's root directory.
- Open the File Manager in your hosting control panel.
- Look for an existing
php.inifile in the root directory, or create a new one if it does not exist. - Add or modify the following line:
memory_limit = 256M
- Save the file and test your website.
Method 3: Using .htaccess
If your server runs Apache, you can set the memory limit in your .htaccess file.
- Open the File Manager in your hosting control panel.
- Locate the
.htaccessfile in the root directory. If you cannot see it, enable the option to show hidden files. - Add the following line at the end of the file:
php_value memory_limit 256M
- Save the file and refresh your website to confirm the change took effect.
Method 4: Using user.ini
Some Australian shared hosting environments using PHP-FPM support a user.ini file for per-directory settings.
- Create or edit the
user.inifile in your website's root directory. - Add the following line:
memory_limit = 256M
- Save the file and test your website.
wp-config.php, php.ini, .htaccess, and user.ini settings. If your changes do not appear in Site Health or phpinfo(), your host has likely locked the memory limit at the server level.Troubleshooting Non-WordPress PHP Applications
If your website is a custom PHP application or uses another content management system, follow these steps:
- Review your application's configuration files for memory limit definitions.
- Check the application's error logs for "Allowed memory size exhausted" messages.
- Identify large array operations, image processing functions, or external API calls that may be consuming excessive memory.
- Use
memory_get_usage()andmemory_get_peak_usage()in your PHP scripts to monitor consumption during execution. - If the application relies on composer dependencies, ensure you are not loading unnecessary packages on every request.
Performance Optimisations and Alternatives
Before requesting a memory increase, consider whether opcode caching or other optimisations can reduce memory pressure:
- Opcode caching: Enabling OPcache stores precompiled script bytecode in shared memory, reducing the need for PHP to recompile scripts on every request. Many Australian shared hosting providers enable this by default; check your hosting control panel for a PHP Settings or Select PHP Version option.
- Caching plugins: For WordPress, install a caching plugin to serve static HTML pages and reduce PHP execution.
- Image optimisation: Compress images before uploading to reduce the memory required for image processing.
- Database optimisation: Clean up post revisions, spam comments, and transient options to reduce database load.
Common Indicators of an Outgrown Plan
- Frequent 500 Internal Server Error messages.
- Database connection errors during peak traffic hours.
- Slow admin dashboard response times.
- Timeouts when uploading large media files.
- Memory limit errors that persist after optimising code and plugins.
When to Contact Hosting Support
Contact your hosting provider's support team during Australian business hours if:
- Your memory limit changes do not take effect, indicating a hard server-level limit.
- You need to verify whether opcode caching is enabled on your account.
- You suspect another account on the shared server is consuming excessive resources and affecting your site.
- You require a plan upgrade to a higher memory allocation.
If you have optimised your application, checked cron jobs, and attempted memory limit changes but continue to experience unreliability, it may be time to migrate to a VPS or dedicated hosting environment. You can discuss upgrade options by visiting the support portal: Open a Ticket.
Still Having Issues?
💻 Open a Ticket