Skip to content

Instantly share code, notes, and snippets.

@arispublic
Last active November 7, 2019 02:00
Show Gist options
  • Save arispublic/8cbd96eee38fdc316e4eb3693ba4c740 to your computer and use it in GitHub Desktop.
Save arispublic/8cbd96eee38fdc316e4eb3693ba4c740 to your computer and use it in GitHub Desktop.
Fix Out of memory issue in preg_replace syntax
<?php
/**
* If you have a PHP Fatal error: Out of memory (allocated 147161088) (tried to allocate 42524112 bytes) in /wp-includes/wp-db.php on line 3042
* It's probably due to the preg_replace is still keep the memory used in previous process.
* I added the code below to wp-db.php file and the problem is gone. But you have to hack the wordpress core code, which is not a good practice.
*/
for ($i = 0; $i < 4096; $i++) {
preg_replace('/\d/', '', 1);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment