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