WordPress Fatal Error Out of Memory

fatal error out of memory

How I Resolved ‘Fatal Error Out of Memory’ For A Single Post

After much editing  of my WordPress post entitled ‘How A Toilet Silent Fill Valve Works’ , since I wrote it in May 2014, (there must have been at least 150 edits, and I changed it from a page to a post too) I suddenly had this ‘Fatal Error Out of Memory’ script on the WordPress White Screen of Death when I tried to edit it:

Fatal error: Out of memory (allocated 54001664) (tried to allocate 49253 bytes) in /homepages/22/d382273723/htdocs/wp-includes/wp-db.php on line 1380

I downloaded the file . . . /wp-db.php and loaded it into a php editor to examine line 1380.

The PHP editor I used was Code Lobster. You can see here the offending line 1380 in the public function flush():

fatal error out of memory
Exert from wp-db.php

It was a large post with several images and many links to anchors in the same post. It also linked to another post in my blog. Fortunately the page displayed OK in a browser, so people viewing my blog could see it allowing me to leave it in that state for a few weeks. However I did want to edit it, so I needed to fix the problem. I didn’t know how to resolve the problem, which was only affecting this one post, by editing the php file, so I resolved my problem in the following way. I chose to re-write the post and throw the old one in the bin.

Fortunately I could use Quick Edit Which allowed me to change the Title, Slug and change from Published to Draft. It also allowed me to make a note of the date and time the original was published. I could then edit the date and time when I published the new draft.

NOTE: I was using WP 4.2.2 and the Twenty Fourteen theme modified.

My Method For Re-writing The Post

I began the re-write with a new draft using a different title to the original. I just missed a word out of the original title and made sure it was missed out of the permalink too. I then highlighted all of the old post in my browser and copied it. I then pasted that into Windows Notepad. That got rid of the images, links and formatting leaving me with plain text. The text did include image captions which ultimately had to be deleted, but they reminded me where to insert the images. I then copied all the text from Notepad and pasted it into the new draft. Then I spent the rest of the day editing (mostly reformatting) all the text, headings, etc., and re-inserting the images, anchors, links, and SEO Focus Keyword and Meta Description. (I use SEO by Yoast.)

When I was happy that the new post links worked OK, by previewing the draft, I changed the title and slug (permalink) of the original faulty post using Quick Edit by just removing a word from the title and slug (not the same word that I removed in the draft) keeping the title different from the draft. That took the original post out of service. Then I edited the draft title and permalink to make them identical to the original post, as it was originally, and Published it. That made the new post I had drafted active so it would appear on my site in place of the original. Then I edited the published date and time to back date it to the original date else it would be younger than its comments.

I then used a plugin I already had installed entitled ‘Tako Movable Comments’ to move all the comments from the original faulty post to the new one I had created. Then I used Quick Edit again on the original faulty post to change it from Published to Draft to take it out of the public domain but leave it available for me to carry out further tests on it and copy the error to enable writing of this post.

Since I fixed my post I have found this post in the Beginners Guide To WordPress which could help anyone encountering the WordPress White Screen of Death.

Author: Helpful Colin

I have a background in telecommunications and a fascination with all things scientific and technical - from physics to electronics, and computing to DIY.

Please Comment Below (or Select An Existing Comment's "REPLY" Button First) - See HELP for Details.