WordPress Out OF Memory Exceptions

wordpress out of memory post thumbnail
Home » Blog » WordPress Out OF Memory Exceptions
Free Web Marketing Consultations

Helping B2B Technology Companies Increase Their Lead Volume.
Serving: IT, MSP, Cybersecurity, Software Dev, SaaS, ISV, VARs & More.

Table of Contents
    Add a header to begin generating the table of contents

    Recently I’ve been dabbling in programmatic SEO. I got an idea of rolling out a landing page to attract search engine traffic from every major city in the United States and came up a with a solution to bulk create a lot of pages in WordPress, including a page for all 50 states in the U.S. and the top cities that met a certain population requirement in each state. All in all this wound up being around 500 pages worth of content.

    Unfortunately my WordPress instance’s ability to handle such volume exceed my ambitions and I quickly started noticing a lot of out of memory exceptions in WordPress, notably in any place where a list of pages needed to be loaded. I wound up dialing the number of pages back to 350 pages, but even that required some troubleshooting steps and changes to be able to publish that volume on top of the already robust set of landing pages that my site contained. In this post I’ll talk a little bit about WordPress out of memory exceptions that can start appearing on a site when it gets too large.

    What Is An Out Of Memory Exception In WordPress?

    Each time a visitor comes to your WordPress site a thread is allocated to handle delivering your site to that visitor. WordPress sites need a pool of threads to be able to handle multiple visitors potentially hitting the website at the same time. Each thread is going to have a certain maximum size typically expressed in Megabytes. The total amount of threads and their maximum sizes add up the total memory pool.

    Think about a thread like a hallway that only one person can walk through at a time. Think about that like how big the hallway. How big the hallway is dictates how big of a person could feasibly walk through it. As long as the hallways is big enough to accomodate the person walking through the hallway, everything works fine. But if someone big, HUGE, like Andre The Giant or The Rock tries to walk through a tiny hallway and can’t fit, well that’s basically like an out of memory exception in WordPress.

    When the total size of the request exceeds the maximum size of a thread, it results in an out of memory exception.

    Why Would Too Many Pages Create An Out Of Memory Exception In WordPress?

    I first noticed this error when looking at the Yoast sitemap after publishing the initial 500 pages of content, but was also noticing the out of memory exceptions happening when trying to load the all pages view and when trying to load the menu pages, which load a list of pages you can choose to add to the menu.

    I was a little agitated because loading a list of pages should be a relatively simple and small query to run that shouldn’t really be resulting in out of memory exceptions. But with WordPress the simple and easy comes at the beginning and the headaches pile up as you scale. A trade off most are willing to make with websites.

    My website is using a page builder, Beaver Builder to be more specific, and most page builders store all of the data they use to display a page within the post_meta table in WordPress. Unfortunately the database queries that were driving the display of these pages were querying data from the post_meta table along with the posts table.

    The post_meta table is a flexible table designed to store simple metadata about a post such as date published. It was never really intended to store massive columns of data such as a full page of HTML data but this is the solution many page builders leverage and since many WordPress sites leverage page builders, it’s a common issue to have the post_meta table be the culprit of WordPress out of memory exceptions.

    In general database queries are typically the cause of the out of memory exceptions since they are likely to load large chunks of data into memory as part of processing a request to deliver a page in WordPress.

    Troubleshooting WordPress Out Of Memory Exceptions

    Since database queries are the most likely culprit a good first troubleshooting step is to look at the largest tables in your database. You can identify the largest tables in your WordPress instance in the popular PHPMyAdmin by clicking on the database name and sorting by the size of the database table.

    As you can see the post Meta table, even after preening it down from what was originally over 1GB in size is the largest at over 500 MB. This is pretty common when troubleshooting out of memory exceptions in WordPress but it could also be other tables.

    If it is the post meta table as it was in this case you can use a SQL query like this (while substituting you table prefix) to identify what the largest post meta values are.

    SELECT length(meta_value), meta_key, meta_value FROM `wp_postmeta` GROUP BY meta_value ORDER BY length(meta_value) desc LIMIT 10;

    The length(meta_value) value is the length in bytes of the meta_value column. You can see in the screenshot below that there are post_meta rows where the meta value is 1127262 bytes or 1.12 Megabytes. This is the html data being stored by Beaver Builder for certain individual pages. Before cleanup there were duplicate values for drafts and revisions being stored in the database and with almost 600 total pages of content in the Tortoise and Hare website’s WordPress database and some over 1MB in size each it was easy to see how the table size could bloat.

    Fixing The WordPress Out Of Memory Exceptions On Certain Pages

    Fixing the out of memory exceptions took a couple of steps. First we expanded the amount of memory per thread via our hosting provider Kinsta. Even after we had dialed back the number of pages we were going to publish the post_meta table was large and the need to have an expanded thread memory size was required. We increased the total memory pool to 4GB with 4 threads at roughly 1GB each. Not the most elegant solution, but it worked.

    Second we cleaned up the post meta table as much as we could to reduce the amount of unnecessary large rows. In this case we ran a Beaver Builder database cleanup utility that allowed us to purge drafts and revisions. We also deleted some other unnecessary rows from other plugins storing some non critical metadata about certain pages. Overall this brought the total size of the down from roughly 1.3 GB (more than the maximum allowable thread size) down to about 500MB. This shaved the query size down below the maximum memory per thread.

    Pinpointing the specific cause of an out of memory error on WordPress can be challenging. It requires understanding of the database, ability to review error logs for clues, and understanding of the hosting configuration for thread counts and thread memory. Fixing the out of memory errors usually requires tweaks to one or more of these areas or a compromise on the plugins and features used by a WordPress instance.

    Help With Fixing An Out Of Memory Error On WordPress

    Troubleshooting out of memory exceptions can be a pain if you don’t know what you’re doing but they are a common error on WordPress site. Hopefully this post gave you some context that can help you troubleshoot your own out of memory errors. But, If you need helping fixing an out of memory error on WordPress, contact us and we can help you troubleshoot and repair your WordPress instance for an hourly fee.

    Share This Article
    Posted in:
    Tagged: ,

    Hunter Nelson

    Hunter is the founder and president of Tortoise and Hare Software, a digital marketing agency for the technology sector and other lead generation oriented businesses. Hunter has more than 10 years’ experience building web applications and crafting digital strategies for companies ranging from scrappy startups to Fortune 50 household names. When not on the clock, you'll find him spending time with his family and pups, relaxing on the beach, or playing competitive online video games. See for more.

    Leave a Comment





    Recent Blog Posts

    SEO Not Working: Here’s Why

    Lately I’ve been getting on more and more calls lately with people saying something along the lines of “we’ve been doing SEO or inbound for 6 months, 12 months, or…

    Why SEO Investments Help Your MSP Weather a Recession and Keep the Door Open for New Opportunities

    What happens to your pipeline when the phones go quiet, inboxes stay cold, and paid ads stop converting? That’s not a hypothetical. It’s what happens in a recession. Budgets freeze.…

    MSP Marketing – How to Build a Strategy That Works

    Let’s be honest—most MSP marketing doesn’t work.Not because the tactics are bad, but because they’re unaligned. What looks like a marketing problem is often a strategy problem in disguise. Most…

    The 10 Best MSP SEO Agencies To Help You Grow Organic Traffic

    If you’re searching for SEO agencies for MSPs, the list of generalists can feel endless—and underwhelming. Most SEO providers don’t understand the managed services space, much less the buyer behavior,…

    Why Your MSP’s Online Marketing Efforts Are Failing

    If you’re leading an MSP and investing in online marketing, you’re probably feeling a growing sense of frustration. You’ve put money into websites, content, ads—even hired an agency or two…

    What Makes a Great MSP Website? 5 Examples You Should Follow

    Your MSP website is more than just an online brochure—it’s a powerful tool for attracting and converting potential clients. But what makes a website truly effective in the competitive managed…

    Related Blog Posts

    How To Generate More MSP Website Leads With A Primary Call To Action

    In today’s digital age, your Managed Service Provider (MSP) website serves as the cornerstone of your online presence. It’s the virtual gateway for potential clients to explore your services, expertise,…

    Your WP Server Cache Might Be Costing You Leads

    Over the past 3 months I’ve been battling an infuriating and troubling issue. Some of my WordPress site’s forms were not submitting! But not all the time, just some of…

    Why We Recommend Page Builder Websites For Startups

    If there’s one word that characterizes startup companies it’s instability. I see this across service providers like IT companies and product companies like SaaS startups. Small and growing companies oftentimes…

    Why A B2B Website Should Cost $10,000+

    In today’s post, I want to break down a common misalignment between B2B website purchasers and agencies when it comes to website development. Website pricing, like all goods and services,…

    The 5 Second Test For PPC Landing Pages

    I’ve been having a lot of conversations recently about optimizing websites for lead generation and explaining a concept called the 5 second test. The 5 second test is a design…

    Why You Should Keep Your SaaS Installed On A Subdomain

    More than a few SaaS founders start out with a technical background, looking to parlay their coding skills into a product and build a business off it. Their surplus of…

    Top Blog Content

    The Ultimate Guide To MSP SEO

    Search Engine Optimization (SEO) is one of the most important ways to attract new business for mid-market managed service providers (MSP). If you look at MSPs that have achieved any…

    The Ultimate Guide To Paid Search On Google Ads For Managed Service Providers

    Generating leads for your MSP can be a challenge. You spend so much time managing employees, making sure customer support tickets are answered, procuring hardware, and defending against cyber threats,…

    The Ultimate Guide To MSP Website Optimization

    A well-optimized website is essential for Managed Service Providers (MSPs) looking to scale their business, attract more leads, and achieve a lucrative exit. A lot of MSPs check a few…

    The Ultimate Guide to Hiring an MSP Marketing Agency

    Are you one of the many MSPs struggling to attract new clients consistently? According to research conducted by MSP Dojo, a leading MSP sales consulting firm, approximately 85% of MSPs…

    The Ultimate Guide To Setting A Marketing Budget For IT Companies

    Many IT companies get their start as a one-man operation and rely almost exclusively on word of mouth, referrals, and other organic offline means to get past their initial growth…

    Featured Review of Tortoise and Hare

    ryan drake president nettech consultants
    R.D.
    President Florida Based MSP

    Tortoise and Hare has been a key partner in our MSP's growth. Over the year's we've worked together they've helped our MSP dramatically increase our website traffic, and build a steady stream of leads sourced from our website and advertising efforts. Over that time, we've been able to raise our base customer size, build economies of scale to more efficiently service customers, and expand into new markets.