Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How can I free up the memory used by update_post_meta?

It turns out that it was due to Query Monitor, a plugin that records info about each query. Every time update_post_meta ran, Query Monitor would store some data about the query, which eventually added up to be more than the server could handle.

Running my example code on a default theme like Twenty Nineteen with no other plugins enabled results in the expected behavior:

...

Used memory 1: 5480528
Used memory 2: 5480528

Used memory 1: 5480528
Used memory 2: 5480528

...

So if you’re running into a similar issue, try disabling all of your plugins and switching to a default theme to help narrow down the issue.

update_post_meta doesn’t appear to be the problem, at least not by itself.

Related Posts:

  1. Insert, update or remove data from database (usermeta)
  2. WordPress delete mysql rows with string
  3. Should I use wpdb prepare?
  4. Post meta vs separate database tables
  5. WP_Query leaking absurd amounts of memory
  6. Is get_option() faster than accessing get_transient()?
  7. Best practices for using the transients API
  8. Trouble with Transient API when W3TC is activated [closed]
  9. Getting wrong relationship value in $args in wp_Query?
  10. How to make dynamically-generated content searchable in WordPress?
  11. Does using set_transient() function can lead to MySQL problems?
  12. Save metabox with multiple checkbox array
  13. How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
  14. How is the data stored in the database?
  15. How to enable users to down-vote in this simple voting counter (that uses the post meta)?
  16. Passing array of strings to a SQL statement in a WordPress plugin
  17. Is there a way to list tags order by post_meta field
  18. Activation hook not creating table
  19. Is the usage of ON DELETE CASCADE wrong or not allowed on wordpress?
  20. How can I render shortcode so that its not cached by Caching plugins?
  21. How to edit mySQL wp_posts table from plugin php?
  22. Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
  23. Plugin development: get_post_meta is not working [closed]
  24. Ordering posts by metadata
  25. $wpdb -> Batch insert from XML File?
  26. Does WordPress’s HTTP API use any caching?
  27. query users by role
  28. Will cron job run if page loaded is being served from cache?
  29. Is using WP Transients to save external data for a plugin the best/right way?
  30. Act on user meta updated, but only once
  31. Cache directory needed for plugin
  32. How to check if Woocommerce Order number equals to post ID?
  33. Clearing cached plugin data if it is using an external object cache
  34. update post meta for checkbox in the admin when inserted in the front-end
  35. 403 Error when text is pasted in Custom Metabox Textarea
  36. WordPress database error for query INSERT INTO
  37. How to connect to AWS RDS external database (not for the core WordPress db)
  38. Make WordPress cache permanent for some pages until edited
  39. Will setcookie work if there is a cache plugin installed?
  40. Maximum lifetime for nonce
  41. Clearing caches on plugin uninstall
  42. How to implement filesystem cache in WordPress
  43. Saving value of a selection option in comment form as comment meta
  44. Add a Save Button to Custom Meta Box [duplicate]
  45. Plugin with action ‘save_post’ needs to press publish twice on order to publish
  46. Is using custom table to suit business needs instead of transients a big hit to page load speed?
  47. Doubts about the use of metadata and how this can affect performance on WordPress
  48. update_post_meta not working in a loop
  49. $wpdb->prepare with LIKE and sprintf
  50. Alternative functions for mysql_free_result and mysql_ping in wordpress functions
  51. WP nonce field checkbox prints checked=’checked’ outside input field
  52. Ajax: Populate with content from a post’s ID not working – duplicating current page html instead
  53. Using AND and bracket grouping in SQL not working
  54. Issues Updating Post Meta with AJAX (Seems simple but cannot figure it out)
  55. Two different wordpress sites – same server and IP address. Gaining Access to database 1 of 2
  56. Service Worker Uncaught (in promise) DOMException
  57. Should I use wp-content/cache or [PLUGIN_DIR]/cache?
  58. I need to refresh page to display wp_get_current_user() : why?
  59. How can I programmatically change a MySql variable (foreign_keys_check)?
  60. How can I control if post updated
  61. Using delete_post_meta for deleting multiple selected options
  62. Auto-complete or auto-suggest from stored data in database
  63. Get audio metadata on file upload
  64. What might be the reason of Couldn’t fetch mysqli_result on another domain?
  65. $wpdb->prepare is not working like mysql_real_escape_string
  66. Brainstorm – Slow Query from Plugin Need to Speed It Up
  67. Plugin can’t be activated [closed]
  68. Create an user on external database
  69. Any way to update_post_meta with html content? It gets stripped and becomes empty
  70. What could cause a WP Option to get truncated?
  71. Remove Meta-boxes (Yoast SEO plugin) [duplicate]
  72. Is there a way to add a link with add_post_meta?
  73. Adjust query on single
  74. WordPress database error: [Query was empty] – using $wpdb->prepare()
  75. Foreign wp_users ID in custom plugin DB table?
  76. Why is $_POST empty when saving custom Meta Box?
  77. How to Get Last ID?
  78. Condition to check previous next article post title
  79. register_meta not showing custom post type metabox data in rest api
  80. Undefined cache functions in my custom plugin
  81. WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
  82. Why is that only the first row getting inserted into Mysql table when i import csv file on backend custom plugin?
  83. Error Connecting to Database WHEN Installing WordPress on XAMPP [Tried All the Usual Stuff] (Pics Included)
  84. Is it possible to replace MySQL with JSON files for WordPress
  85. Unexpected issue when using attachment_fields_to_edit filter
  86. WordPress doesn’t create table on plugin activation
  87. Is it possible to restore an expired transient?
  88. Saving post meta
  89. Organising and completing posts (mark as read and hide)
  90. Displaying Custom Post Meta
  91. pull data from wordpress database
  92. Plugin MySQL SELECT custom data and filter on user meta
  93. sql query not working in wp plugin
  94. $wpdb Mysql trigger problem
  95. Custom MySQL query to pull out Advanced Custom Fields?
  96. How to filter get_adjacent_post()?
  97. Plugin files not updated (cache cleared)
  98. $wpdb how can i save my postmeta table before querying it
  99. Include add_post_meta in a plugin
  100. Nothing happens on WordPress Update command
Categories plugin-development Tags cache, memory, mysql, plugin-development, post-meta
array_map() for sanitizing $_POST
Replace existing content from specific WooCommerce admin orders list column

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress